From ff3af2224be10546d3af407815e0c4e742cd4d4e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Sun, 1 Mar 2020 12:33:52 +0100 Subject: [PATCH] Fix flake8 errors and warnings We add the flake8 configuration used so we ensure everyone uses the same. We remove the usage of __all__ for non public API. When possible, we rationalize the class name according to its __name__ and module. issue9082 review297061002 --- .flake8 | 2 ++ __init__.py | 12 ++++++------ product.py | 9 +++------ setup.py | 7 ++++--- tests/__init__.py | 2 +- 5 files changed, 16 insertions(+), 16 deletions(-) create mode 100644 .flake8 diff --git a/.flake8 b/.flake8 new file mode 100644 index 0000000000..bb03d08a82 --- /dev/null +++ b/.flake8 @@ -0,0 +1,2 @@ +[flake8] +ignore=E123,E124,E126,E128,W503 diff --git a/__init__.py b/__init__.py index 7460d69c2d..2c388beae8 100644 --- a/__init__.py +++ b/__init__.py @@ -2,14 +2,14 @@ # this repository contains the full copyright notices and license terms. from trytond.pool import Pool -from .product import * +from . import product def register(): Pool.register( - ProductAttributeSet, - ProductAttribute, - ProductAttributeAttributeSet, - Template, - Product, + product.AttributeSet, + product.Attribute, + product.AttributeAttributeSet, + product.Template, + product.Product, module='product_attribute', type_='model') diff --git a/product.py b/product.py index fdd5eb85a4..eb779bc93c 100644 --- a/product.py +++ b/product.py @@ -4,11 +4,8 @@ from trytond.model import ModelSQL, ModelView, DictSchemaMixin, fields from trytond.pool import PoolMeta from trytond.pyson import Eval -__all__ = ['ProductAttributeSet', 'ProductAttribute', - 'ProductAttributeAttributeSet', 'Template', 'Product'] - -class ProductAttributeSet(ModelSQL, ModelView, metaclass=PoolMeta): +class AttributeSet(ModelSQL, ModelView, metaclass=PoolMeta): "Product Attribute Set" __name__ = 'product.attribute.set' name = fields.Char('Name', required=True, translate=True, @@ -18,7 +15,7 @@ class ProductAttributeSet(ModelSQL, ModelView, metaclass=PoolMeta): help="Add attributes to the set.") -class ProductAttribute(DictSchemaMixin, ModelSQL, ModelView, metaclass=PoolMeta): +class Attribute(DictSchemaMixin, ModelSQL, ModelView, metaclass=PoolMeta): "Product Attribute" __name__ = 'product.attribute' sets = fields.Many2Many('product.attribute-product.attribute-set', @@ -26,7 +23,7 @@ class ProductAttribute(DictSchemaMixin, ModelSQL, ModelView, metaclass=PoolMeta) help="Add sets to the attribute.") -class ProductAttributeAttributeSet(ModelSQL, metaclass=PoolMeta): +class AttributeAttributeSet(ModelSQL, metaclass=PoolMeta): "Product Attribute - Set" __name__ = 'product.attribute-product.attribute-set' attribute = fields.Many2One('product.attribute', 'Attribute', diff --git a/setup.py b/setup.py index 94bd1ac115..371878a70a 100755 --- a/setup.py +++ b/setup.py @@ -78,8 +78,8 @@ setup(name=name, keywords='tryton product attribute', package_dir={'trytond.modules.product_attribute': '.'}, packages=( - ['trytond.modules.product_attribute'] + - ['trytond.modules.product_attribute.%s' % p for p in find_packages()] + ['trytond.modules.product_attribute'] + + ['trytond.modules.product_attribute.%s' % p for p in find_packages()] ), package_data={ 'trytond.modules.product_attribute': (info.get('xml', []) @@ -93,7 +93,8 @@ setup(name=name, 'Intended Audience :: Financial and Insurance Industry', 'Intended Audience :: Legal Industry', 'Intended Audience :: Manufacturing', - 'License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)', + 'License :: OSI Approved :: ' + 'GNU General Public License v3 or later (GPLv3+)', 'Natural Language :: Bulgarian', 'Natural Language :: Catalan', 'Natural Language :: Chinese (Simplified)', diff --git a/tests/__init__.py b/tests/__init__.py index c5dad973d9..d1bfa491f9 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -2,7 +2,7 @@ # this repository contains the full copyright notices and license terms. try: - from trytond.modules.product_attribute.tests.test_product_attribute import suite + from trytond.modules.product_attribute.tests.test_product_attribute import suite # noqa: E501 except ImportError: from .test_product_attribute import suite