changeset d9dd213042d8 in modules/product:default
details: https://hg.tryton.org/modules/product?cmd=changeset;node=d9dd213042d8
description:
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
diffstat:
.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(-)
diffs (140 lines):
diff -r fc86e8c0264c -r d9dd213042d8 .flake8
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/.flake8 Sun Mar 01 12:33:52 2020 +0100
@@ -0,0 +1,2 @@
+[flake8]
+ignore=E123,E124,E126,E128,W503
diff -r fc86e8c0264c -r d9dd213042d8 __init__.py
--- a/__init__.py Sun Feb 23 13:56:58 2020 +0100
+++ b/__init__.py Sun Mar 01 12:33:52 2020 +0100
@@ -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 -r fc86e8c0264c -r d9dd213042d8 category.py
--- a/category.py Sun Feb 23 13:56:58 2020 +0100
+++ b/category.py Sun Mar 01 12:33:52 2020 +0100
@@ -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 -r fc86e8c0264c -r d9dd213042d8 configuration.py
--- a/configuration.py Sun Feb 23 13:56:58 2020 +0100
+++ b/configuration.py Sun Mar 01 12:33:52 2020 +0100
@@ -6,7 +6,6 @@
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 -r fc86e8c0264c -r d9dd213042d8 product.py
--- a/product.py Sun Feb 23 13:56:58 2020 +0100
+++ b/product.py Sun Mar 01 12:33:52 2020 +0100
@@ -25,9 +25,7 @@
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 @@
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 -r fc86e8c0264c -r d9dd213042d8 setup.py
--- a/setup.py Sun Feb 23 13:56:58 2020 +0100
+++ b/setup.py Sun Mar 01 12:33:52 2020 +0100
@@ -79,8 +79,8 @@
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 @@
'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 -r fc86e8c0264c -r d9dd213042d8 uom.py
--- a/uom.py Sun Feb 23 13:56:58 2020 +0100
+++ b/uom.py Sun Mar 01 12:33:52 2020 +0100
@@ -13,7 +13,7 @@
from .exceptions import UOMValidationError
-__all__ = ['UomCategory', 'Uom', 'uom_conversion_digits']
+__all__ = ['uom_conversion_digits']
STATES = {
'readonly': ~Eval('active', True),