From 8ff601e98138f72e46dc7a23940f193c08f59b85 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Sun, 1 Mar 2020 12:33:53 +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 | 12 ++++++------ routing.py | 2 -- setup.py | 7 ++++--- tests/__init__.py | 2 +- timesheet.py | 8 +++----- work.py | 2 -- 7 files changed, 16 insertions(+), 19 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 ef45740268..c71dd2664a 100644 --- a/__init__.py +++ b/__init__.py @@ -2,14 +2,14 @@ # this repository contains the full copyright notices and license terms. from trytond.pool import Pool -from .work import * -from .routing import * -from .timesheet import * +from . import work +from . import routing +from . import timesheet def register(): Pool.register( - Work, - Operation, - TimesheetWork, + work.Work, + routing.Operation, + timesheet.Work, module='production_work_timesheet', type_='model') diff --git a/routing.py b/routing.py index 172a4ef792..dfde074513 100644 --- a/routing.py +++ b/routing.py @@ -3,8 +3,6 @@ from trytond.pool import PoolMeta from trytond.model import fields -__all__ = ['Operation'] - class Operation(metaclass=PoolMeta): __name__ = 'production.routing.operation' diff --git a/setup.py b/setup.py index 90c1168d7b..8e79d1072d 100755 --- a/setup.py +++ b/setup.py @@ -80,8 +80,8 @@ setup(name=name, keywords='tryton production work timesheet', package_dir={'trytond.modules.production_work_timesheet': '.'}, packages=( - ['trytond.modules.production_work_timesheet'] + - ['trytond.modules.production_work_timesheet.%s' % p + ['trytond.modules.production_work_timesheet'] + + ['trytond.modules.production_work_timesheet.%s' % p for p in find_packages()] ), package_data={ @@ -96,7 +96,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 :: Czech', diff --git a/tests/__init__.py b/tests/__init__.py index cef34c80b4..c24ddea355 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -2,7 +2,7 @@ # this repository contains the full copyright notices and license terms. try: - from trytond.modules.production_work_timesheet.tests.test_production_work_timesheet import suite + from trytond.modules.production_work_timesheet.tests.test_production_work_timesheet import suite # noqa: E501 except ImportError: from .test_production_work_timesheet import suite diff --git a/timesheet.py b/timesheet.py index a4ebbc6d37..082995435f 100644 --- a/timesheet.py +++ b/timesheet.py @@ -2,20 +2,18 @@ # this repository contains the full copyright notices and license terms. from trytond.pool import PoolMeta, Pool -__all__ = ['TimesheetWork'] - -class TimesheetWork(metaclass=PoolMeta): +class Work(metaclass=PoolMeta): __name__ = 'timesheet.work' @classmethod def _get_origin(cls): - return super(TimesheetWork, cls)._get_origin() + ['production.work'] + return super()._get_origin() + ['production.work'] def _validate_company(self): pool = Pool() ProductionWork = pool.get('production.work') - result = super(TimesheetWork, self)._validate_company() + result = super()._validate_company() if isinstance(self.origin, ProductionWork): result &= self.company == self.origin.company return result diff --git a/work.py b/work.py index a9bbab3772..0336c202b1 100644 --- a/work.py +++ b/work.py @@ -6,8 +6,6 @@ from trytond.pool import PoolMeta, Pool from trytond.model import fields from trytond.pyson import Eval -__all__ = ['Work'] - class Work(metaclass=PoolMeta): __name__ = 'production.work'