From 1c3e728871b5d3d165e67f5bc537dc798ca7e479 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Sun, 1 Mar 2020 12:33:51 +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 | 2 +- account.py | 2 -- journal.py | 8 +++----- party.py | 6 ++---- setup.py | 7 ++++--- statement.py | 11 +++++++---- tests/__init__.py | 2 +- 8 files changed, 20 insertions(+), 20 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 4456de0ebd..d4b736710b 100644 --- a/__init__.py +++ b/__init__.py @@ -21,7 +21,7 @@ def register(): statement.ImportStatementStart, module='account_statement', type_='model') Pool.register( - party.PartyReplace, + party.Replace, statement.ImportStatement, statement.ReconcileStatement, module='account_statement', type_='wizard') diff --git a/account.py b/account.py index 0331bca8f0..fe424bd6ce 100644 --- a/account.py +++ b/account.py @@ -13,8 +13,6 @@ from trytond.tools import grouped_slice, reduce_ids from trytond.modules.account.exceptions import PostError -__all__ = ['Journal', 'Move'] - class Journal(metaclass=PoolMeta): __name__ = 'account.journal' diff --git a/journal.py b/journal.py index 08811f2707..4e8de323db 100644 --- a/journal.py +++ b/journal.py @@ -8,8 +8,6 @@ from trytond.transaction import Transaction from trytond.pool import Pool from trytond.pyson import Eval -__all__ = ['Journal'] - class Journal(ModelSQL, ModelView): 'Statement Journal' @@ -68,9 +66,9 @@ class Journal(ModelSQL, ModelView): # Migration from 4.8: new account field if created_account and table.table_exist('account_journal_account'): value = journal_account.select(journal_account.credit_account, - where=((journal_account.journal == sql_table.journal) & - (journal_account.credit_account == - journal_account.debit_account))) + where=((journal_account.journal == sql_table.journal) + & (journal_account.credit_account + == journal_account.debit_account))) # Don't use UPDATE FROM because SQLite does not support it. cursor.execute(*sql_table.update([sql_table.account], [value])) diff --git a/party.py b/party.py index d879f7e63b..13a5d94501 100644 --- a/party.py +++ b/party.py @@ -2,14 +2,12 @@ # this repository contains the full copyright notices and license terms. from trytond.pool import PoolMeta -__all__ = ['PartyReplace'] - -class PartyReplace(metaclass=PoolMeta): +class Replace(metaclass=PoolMeta): __name__ = 'party.replace' @classmethod def fields_to_replace(cls): - return super(PartyReplace, cls).fields_to_replace() + [ + return super().fields_to_replace() + [ ('account.statement.line', 'party'), ] diff --git a/setup.py b/setup.py index 65e2090113..10779017ba 100755 --- a/setup.py +++ b/setup.py @@ -79,8 +79,8 @@ setup(name=name, keywords='tryton account statement', package_dir={'trytond.modules.account_statement': '.'}, packages=( - ['trytond.modules.account_statement'] + - ['trytond.modules.account_statement.%s' % p for p in find_packages()] + ['trytond.modules.account_statement'] + + ['trytond.modules.account_statement.%s' % p for p in find_packages()] ), package_data={ 'trytond.modules.account_statement': (info.get('xml', []) @@ -94,7 +94,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)', diff --git a/statement.py b/statement.py index 9548eaa619..7d955be1e3 100644 --- a/statement.py +++ b/statement.py @@ -748,8 +748,8 @@ class Line( super(Line, cls).__setup__() if 'origin' not in cls.date.depends: cls.date.states.update({ - 'readonly': (cls.date.states['readonly'] | - Bool(Eval('origin', 0))), + 'readonly': (cls.date.states['readonly'] + | Bool(Eval('origin', 0))), }) cls.date.depends.append('origin') cls.account.required = True @@ -959,6 +959,7 @@ class Line( amount_second_currency=amount_second_currency, ) + del _states, _depends @@ -1049,8 +1050,8 @@ class Origin(origin_mixin(_states, _depends), ModelSQL, ModelView): lines = fields.One2Many( 'account.statement.line', 'origin', "Lines", states={ - 'readonly': ((Eval('statement_id', -1) < 0) | - ~Eval('statement_state').in_(['draft', 'validated'])), + 'readonly': ((Eval('statement_id', -1) < 0) + | ~Eval('statement_state').in_(['draft', 'validated'])), }, domain=[ ('statement', '=', Eval('statement')), @@ -1104,6 +1105,8 @@ class Origin(origin_mixin(_states, _depends), ModelSQL, ModelView): table.amount - Coalesce(Sum(line.amount), 0), value), group_by=table.id)) return [('id', 'in', query)] + + del _states, _depends diff --git a/tests/__init__.py b/tests/__init__.py index bfcd32362d..a0c6aba0ff 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.account_statement.tests.test_account_statement import suite + from trytond.modules.account_statement.tests.test_account_statement import suite # noqa: E501 except ImportError: from .test_account_statement import suite