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 committed 2020-03-01 12:33:53 +01:00
1 parent 261ff89625
commit e352e789de
4 files changed
+18 -18

No files matched your search

+2
View File
@@ -0,0 +1,2 @@
[flake8]
ignore=E123,E124,E126,E128,W503
+6 -6
View File
@@ -2,14 +2,14 @@
# this repository contains the full copyright notices and license terms.
from trytond.pool import Pool
from .sale import *
from . import sale
def register():
Pool.register(
SalePromotion,
SalePromotion_Product,
SalePromotion_ProductCategory,
Sale,
SaleLine,
sale.Promotion,
sale.Promotion_Product,
sale.Promotion_ProductCategory,
sale.Sale,
sale.Line,
module='sale_promotion', type_='model')
+6 -9
View File
@@ -16,9 +16,6 @@ from trytond.tools import decistmt
from trytond.modules.product import price_digits
from .exceptions import FormulaError
__all__ = ['Sale', 'SaleLine',
'SalePromotion', 'SalePromotion_Product', 'SalePromotion_ProductCategory']
class Sale(metaclass=PoolMeta):
__name__ = 'sale.sale'
@@ -70,7 +67,7 @@ class Sale(metaclass=PoolMeta):
promotion.apply(self)
class SaleLine(metaclass=PoolMeta):
class Line(metaclass=PoolMeta):
__name__ = 'sale.line'
draft_unit_price = fields.Numeric('Draft Unit Price',
@@ -82,7 +79,7 @@ class SaleLine(metaclass=PoolMeta):
])
class SalePromotion(
class Promotion(
DeactivableMixin, ModelSQL, ModelView, MatchMixin):
'Sale Promotion'
__name__ = 'sale.promotion'
@@ -149,7 +146,7 @@ class SalePromotion(
@classmethod
def validate(cls, promotions):
super(SalePromotion, cls).validate(promotions)
super().validate(promotions)
for promotion in promotions:
promotion.check_formula()
@@ -215,7 +212,7 @@ class SalePromotion(
pattern = pattern.copy()
if self.quantity > pattern.pop('quantity'):
return False
return super(SalePromotion, self).match(pattern)
return super().match(pattern)
def is_valid_sale_line(self, line):
@@ -278,7 +275,7 @@ class SalePromotion(
return max(simple_eval(decistmt(self.formula), **context), Decimal(0))
class SalePromotion_Product(ModelSQL):
class Promotion_Product(ModelSQL):
'Sale Promotion - Product'
__name__ = 'sale.promotion-product.product'
@@ -288,7 +285,7 @@ class SalePromotion_Product(ModelSQL):
required=True, ondelete='CASCADE')
class SalePromotion_ProductCategory(ModelSQL):
class Promotion_ProductCategory(ModelSQL):
"Sale Promotion - Product Category"
__name__ = 'sale.promotion-product.category'
+4 -3
View File
@@ -79,8 +79,8 @@ setup(name=name,
keywords='tryton sale promotion',
package_dir={'trytond.modules.sale_promotion': '.'},
packages=(
['trytond.modules.sale_promotion'] +
['trytond.modules.sale_promotion.%s' % p for p in find_packages()]
['trytond.modules.sale_promotion']
+ ['trytond.modules.sale_promotion.%s' % p for p in find_packages()]
),
package_data={
'trytond.modules.sale_promotion': (info.get('xml', [])
@@ -93,7 +93,8 @@ setup(name=name,
'Intended Audience :: Developers',
'Intended Audience :: Financial and Insurance Industry',
'Intended Audience :: Legal Industry',
'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)',