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
This commit is contained in:
Cédric Krier committed 2020-03-01 12:33:51 +01:00
1 parent b264ea7874
commit 1c3e728871
8 files changed
+20 -20

No files matched your search

+2
View File
@@ -0,0 +1,2 @@
[flake8]
ignore=E123,E124,E126,E128,W503
+1 -1
View File
@@ -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')
-2
View File
@@ -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'
+3 -5
View File
@@ -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]))
+2 -4
View File
@@ -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'),
]
+4 -3
View File
@@ -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)',
+7 -4
View File
@@ -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
+1 -1
View File
@@ -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