From a5ec9ce2d3b1006572b4c8b6c896e43ca43576c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Sun, 1 Mar 2020 12:33:52 +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 | 6 +++--- currency.py | 8 +++----- setup.py | 9 +++++---- 4 files changed, 13 insertions(+), 12 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 c50ba06f97..f87ce63b6e 100644 --- a/__init__.py +++ b/__init__.py @@ -2,11 +2,11 @@ # this repository contains the full copyright notices and license terms. from trytond.pool import Pool -from .currency import * +from . import currency def register(): Pool.register( - Currency, - Rate, + currency.Currency, + currency.CurrencyRate, module='currency', type_='model') diff --git a/currency.py b/currency.py index 106139ec65..07285f960e 100644 --- a/currency.py +++ b/currency.py @@ -17,8 +17,6 @@ from trytond.pyson import Eval from .exceptions import RateError -__all__ = ['Currency', 'Rate'] - class Currency(DeactivableMixin, ModelSQL, ModelView): 'Currency' @@ -223,8 +221,8 @@ class Currency(DeactivableMixin, ModelSQL, ModelView): return query -class Rate(ModelSQL, ModelView): - 'Rate' +class CurrencyRate(ModelSQL, ModelView): + "Currency Rate" __name__ = 'currency.currency.rate' date = fields.Date('Date', required=True, select=True, help="From when the rate applies.") @@ -236,7 +234,7 @@ class Rate(ModelSQL, ModelView): @classmethod def __setup__(cls): - super(Rate, cls).__setup__() + super().__setup__() t = cls.__table__() cls._sql_constraints = [ ('date_currency_uniq', Unique(t, t.date, t.currency), diff --git a/setup.py b/setup.py index e854890fca..b49d1547ad 100755 --- a/setup.py +++ b/setup.py @@ -79,8 +79,8 @@ setup(name=name, keywords='tryton currency', package_dir={'trytond.modules.currency': '.'}, packages=( - ['trytond.modules.currency'] + - ['trytond.modules.currency.%s' % p for p in find_packages()] + ['trytond.modules.currency'] + + ['trytond.modules.currency.%s' % p for p in find_packages()] ), package_data={ 'trytond.modules.currency': (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)', @@ -139,7 +140,7 @@ setup(name=name, currency = trytond.modules.currency [console_scripts] trytond_import_currencies = trytond.modules.currency.scripts.import_currencies:run [data] - """, + """, # noqa: E501 test_suite='tests', test_loader='trytond.test_loader:Loader', tests_require=tests_require,