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
This commit is contained in:
Cédric Krier
2020-03-01 12:33:52 +01:00
parent b8652ff9e7
commit 8ec0d35758
7 changed files with 32 additions and 28 deletions
+2
View File
@@ -0,0 +1,2 @@
[flake8]
ignore=E123,E124,E126,E128,W503
+22 -17
View File
@@ -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')
-2
View File
@@ -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"
-1
View File
@@ -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")
+3 -4
View File
@@ -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)
+4 -3
View File
@@ -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)',
+1 -1
View File
@@ -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),