From b84bf9598ecdd58011d0dca563b55dfec8f1c062 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Sun, 1 Mar 2020 12:33:54 +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 | 32 ++++++++++++++++---------------- location.py | 3 --- order_point.py | 6 ++---- product.py | 2 -- purchase_request.py | 2 -- setup.py | 7 ++++--- shipment.py | 2 -- stock.py | 6 ++---- 9 files changed, 26 insertions(+), 36 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 48ced90208..4c2c66bd82 100644 --- a/__init__.py +++ b/__init__.py @@ -2,27 +2,27 @@ # this repository contains the full copyright notices and license terms. from trytond.pool import Pool -from .order_point import * -from .product import * -from .purchase_request import * -from .shipment import * -from .location import * +from . import order_point +from . import product +from . import purchase_request +from . import shipment +from . import location from . import stock def register(): Pool.register( - OrderPoint, - Product, - ProductSupplier, - PurchaseConfiguration, - PurchaseConfigurationSupplyPeriod, - PurchaseRequest, - ShipmentInternal, - Location, - LocationLeadTime, - stock.StockSupplyStart, + order_point.OrderPoint, + product.Product, + product.ProductSupplier, + purchase_request.PurchaseConfiguration, + purchase_request.PurchaseConfigurationSupplyPeriod, + purchase_request.PurchaseRequest, + shipment.ShipmentInternal, + location.Location, + location.LocationLeadTime, + stock.SupplyStart, module='stock_supply', type_='model') Pool.register( - stock.StockSupply, + stock.Supply, module='stock_supply', type_='wizard') diff --git a/location.py b/location.py index 77b923d041..7482a148d8 100644 --- a/location.py +++ b/location.py @@ -7,9 +7,6 @@ from trytond.model import fields from trytond.pyson import Eval -__all__ = ['Location', 'LocationLeadTime'] - - class Location(metaclass=PoolMeta): __name__ = 'stock.location' diff --git a/order_point.py b/order_point.py index 78edc426f8..6c5a31a4ce 100644 --- a/order_point.py +++ b/order_point.py @@ -9,8 +9,6 @@ from trytond.transaction import Transaction from .exceptions import OrderPointValidationError -__all__ = ['OrderPoint'] - class OrderPoint(ModelSQL, ModelView): """ @@ -53,7 +51,7 @@ class OrderPoint(ModelSQL, ModelView): states={ 'invisible': Not(Equal(Eval('type'), 'internal')), 'required': ((Eval('type') == 'internal') - & (Eval('min_quantity', None) != None)), + & (Eval('min_quantity', None) != None)), # noqa: E711 }, depends=['type', 'min_quantity']) overflowing_location = fields.Many2One( @@ -62,7 +60,7 @@ class OrderPoint(ModelSQL, ModelView): states={ 'invisible': Eval('type') != 'internal', 'required': ((Eval('type') == 'internal') - & (Eval('max_quantity', None) != None)), + & (Eval('max_quantity', None) != None)), # noqa: E711 }, depends=['type', 'max_quantity']) type = fields.Selection( diff --git a/product.py b/product.py index d1bf442a64..5bb94c78f8 100644 --- a/product.py +++ b/product.py @@ -5,8 +5,6 @@ import datetime from trytond.model import fields from trytond.pool import PoolMeta, Pool -__all__ = ['Product', 'ProductSupplier'] - class Product(metaclass=PoolMeta): __name__ = "product.product" diff --git a/purchase_request.py b/purchase_request.py index 25ccd9d6ec..8d12eacdac 100644 --- a/purchase_request.py +++ b/purchase_request.py @@ -9,8 +9,6 @@ from trytond.transaction import Transaction from trytond.pool import Pool, PoolMeta from trytond.tools import grouped_slice -__all__ = ['PurchaseRequest', 'PurchaseConfiguration', - 'PurchaseConfigurationSupplyPeriod'] supply_period = fields.TimeDelta("Supply Period") diff --git a/setup.py b/setup.py index 2fd11b38b6..e4e1b449f0 100755 --- a/setup.py +++ b/setup.py @@ -78,8 +78,8 @@ setup(name=name, keywords='tryton stock supply', package_dir={'trytond.modules.stock_supply': '.'}, packages=( - ['trytond.modules.stock_supply'] + - ['trytond.modules.stock_supply.%s' % p for p in find_packages()] + ['trytond.modules.stock_supply'] + + ['trytond.modules.stock_supply.%s' % p for p in find_packages()] ), package_data={ 'trytond.modules.stock_supply': (info.get('xml', []) @@ -93,7 +93,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/shipment.py b/shipment.py index 6ef998f4ba..f033fab2f3 100644 --- a/shipment.py +++ b/shipment.py @@ -6,8 +6,6 @@ from trytond.model import ModelView, ModelSQL from trytond.transaction import Transaction from trytond.pool import Pool -__all__ = ['ShipmentInternal'] - class ShipmentInternal(ModelSQL, ModelView): __name__ = 'stock.shipment.internal' diff --git a/stock.py b/stock.py index d1e4e8b4c5..4fd71a2c7d 100644 --- a/stock.py +++ b/stock.py @@ -8,10 +8,8 @@ from trytond.wizard import (Wizard, StateView, StateAction, StateTransition, from .exceptions import SupplyWarning -__all__ = ['StockSupply', 'StockSupplyStart'] - -class StockSupply(Wizard): +class Supply(Wizard): "Supply Stock" __name__ = 'stock.supply' start = StateView( @@ -109,6 +107,6 @@ class StockSupply(Wizard): return self.next_action('purchase') -class StockSupplyStart(ModelView): +class SupplyStart(ModelView): "Supply Stock" __name__ = 'stock.supply.start'