changeset beaf84fdeb45 in modules/sale_promotion:default
details:
https://hg.tryton.org/modules/sale_promotion?cmd=changeset;node=beaf84fdeb45
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 | 12 ++++++------
sale.py | 15 ++++++---------
setup.py | 7 ++++---
4 files changed, 18 insertions(+), 18 deletions(-)
diffs (121 lines):
diff -r 946d78369fdb -r beaf84fdeb45 .flake8
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/.flake8 Sun Mar 01 12:33:53 2020 +0100
@@ -0,0 +1,2 @@
+[flake8]
+ignore=E123,E124,E126,E128,W503
diff -r 946d78369fdb -r beaf84fdeb45 __init__.py
--- a/__init__.py Wed Dec 04 11:09:36 2019 +0100
+++ b/__init__.py Sun Mar 01 12:33:53 2020 +0100
@@ -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')
diff -r 946d78369fdb -r beaf84fdeb45 sale.py
--- a/sale.py Wed Dec 04 11:09:36 2019 +0100
+++ b/sale.py Sun Mar 01 12:33:53 2020 +0100
@@ -16,9 +16,6 @@
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 @@
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 SalePromotion(
+class Promotion(
DeactivableMixin, ModelSQL, ModelView, MatchMixin):
'Sale Promotion'
__name__ = 'sale.promotion'
@@ -149,7 +146,7 @@
@classmethod
def validate(cls, promotions):
- super(SalePromotion, cls).validate(promotions)
+ super().validate(promotions)
for promotion in promotions:
promotion.check_formula()
@@ -215,7 +212,7 @@
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 @@
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 @@
required=True, ondelete='CASCADE')
-class SalePromotion_ProductCategory(ModelSQL):
+class Promotion_ProductCategory(ModelSQL):
"Sale Promotion - Product Category"
__name__ = 'sale.promotion-product.category'
diff -r 946d78369fdb -r beaf84fdeb45 setup.py
--- a/setup.py Wed Dec 04 11:09:36 2019 +0100
+++ b/setup.py Sun Mar 01 12:33:53 2020 +0100
@@ -79,8 +79,8 @@
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 @@
'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)',