From 8ec0d35758970dabb4da1eb582a0a2cf47d5bc10 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 | 39 ++++++++++++++++++++++----------------- category.py | 2 -- configuration.py | 1 - product.py | 7 +++---- setup.py | 7 ++++--- uom.py | 2 +- 7 files changed, 32 insertions(+), 28 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 30e9de8d61..13f5a6b785 100644 --- a/__init__.py +++ b/__init__.py @@ -2,25 +2,30 @@ # this repository contains the full copyright notices and license terms. from trytond.pool import Pool -from .uom import * -from .category import * -from .product import * -from .configuration import * +from . import uom +from . import category +from . import product +from . import configuration +from .product import price_digits +from .uom import uom_conversion_digits + +__all__ = [price_digits, uom_conversion_digits] def register(): Pool.register( - UomCategory, - Uom, - Category, - Template, - Product, - ProductIdentifier, - ProductListPrice, - ProductCostPriceMethod, # before ProductCostPrice for migration - ProductCostPrice, - TemplateCategory, - TemplateCategoryAll, - Configuration, - ConfigurationDefaultCostPriceMethod, + uom.UomCategory, + uom.Uom, + category.Category, + product.Template, + product.Product, + product.ProductIdentifier, + product.ProductListPrice, + # before ProductCostPrice for migration + product.ProductCostPriceMethod, + product.ProductCostPrice, + product.TemplateCategory, + product.TemplateCategoryAll, + configuration.Configuration, + configuration.ConfigurationDefaultCostPriceMethod, module='product', type_='model') diff --git a/category.py b/category.py index 0c98371488..48dccf3880 100644 --- a/category.py +++ b/category.py @@ -2,8 +2,6 @@ # this repository contains the full copyright notices and license terms. from trytond.model import ModelView, ModelSQL, fields, tree -__all__ = ['Category'] - class Category(tree(separator=' / '), ModelSQL, ModelView): "Product Category" diff --git a/configuration.py b/configuration.py index 6f509b2482..882a83ad4d 100644 --- a/configuration.py +++ b/configuration.py @@ -6,7 +6,6 @@ from trytond.model import (ModelView, ModelSQL, ModelSingleton, from trytond.pool import Pool from trytond.tools.multivalue import migrate_property -__all__ = ['Configuration', 'ConfigurationDefaultCostPriceMethod'] default_cost_price_method = fields.Selection( 'get_cost_price_methods', "Default Cost Method") diff --git a/product.py b/product.py index 5f6e5165d6..5af9300441 100644 --- a/product.py +++ b/product.py @@ -25,9 +25,7 @@ from trytond.modules.company.model import ( from .exceptions import InvalidIdentifierCode -__all__ = ['Template', 'Product', 'price_digits', 'TemplateFunction', - 'ProductListPrice', 'ProductCostPriceMethod', 'ProductCostPrice', - 'TemplateCategory', 'TemplateCategoryAll', 'ProductIdentifier'] +__all__ = ['price_digits', 'TemplateFunction'] logger = logging.getLogger(__name__) STATES = { @@ -450,7 +448,8 @@ class ProductCostPriceMethod(ModelSQL, CompanyValueMixin): cursor = Transaction().connection.cursor() exist = backend.TableHandler.table_exist(cls._table) - cost_price_exist = backend.TableHandler.table_exist(ProductCostPrice._table) + cost_price_exist = backend.TableHandler.table_exist( + ProductCostPrice._table) super(ProductCostPriceMethod, cls).__register__(module_name) diff --git a/setup.py b/setup.py index 20b486d967..203cb86a47 100755 --- a/setup.py +++ b/setup.py @@ -79,8 +79,8 @@ setup(name=name, keywords='tryton product', package_dir={'trytond.modules.product': '.'}, packages=( - ['trytond.modules.product'] + - ['trytond.modules.product.%s' % p for p in find_packages()] + ['trytond.modules.product'] + + ['trytond.modules.product.%s' % p for p in find_packages()] ), package_data={ 'trytond.modules.product': (info.get('xml', []) @@ -95,7 +95,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/uom.py b/uom.py index c2c87d9e65..3e35962b2c 100644 --- a/uom.py +++ b/uom.py @@ -13,7 +13,7 @@ from trytond.transaction import Transaction from .exceptions import UOMValidationError -__all__ = ['UomCategory', 'Uom', 'uom_conversion_digits'] +__all__ = ['uom_conversion_digits'] STATES = { 'readonly': ~Eval('active', True),