changeset 12d40183365a in modules/account:default
details: https://hg.tryton.org/modules/account?cmd=changeset;node=12d40183365a
description:
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
diffstat:
.flake8 | 2 ++
account.py | 25 ++++++-------------------
fiscalyear.py | 4 ++--
journal.py | 4 ----
move.py | 36 ++++++++++++++----------------------
move_template.py | 4 ----
party.py | 1 -
period.py | 9 ++++-----
setup.py | 7 ++++---
tax.py | 37 +++++++++++++++----------------------
10 files changed, 47 insertions(+), 82 deletions(-)
diffs (351 lines):
diff -r d7a99724f330 -r 12d40183365a .flake8
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/.flake8 Sun Mar 01 12:33:50 2020 +0100
@@ -0,0 +1,2 @@
+[flake8]
+ignore=E123,E124,E126,E128,W503
diff -r d7a99724f330 -r 12d40183365a account.py
--- a/account.py Wed Feb 12 00:19:27 2020 +0100
+++ b/account.py Sun Mar 01 12:33:50 2020 +0100
@@ -25,19 +25,6 @@
from .common import PeriodMixin, ActivePeriodMixin
from .exceptions import SecondCurrencyError, ChartWarning
-__all__ = ['TypeTemplate', 'Type', 'OpenType',
- 'AccountTemplate', 'AccountTemplateTaxTemplate',
- 'Account', 'AccountDeferral', 'AccountTax',
- 'OpenChartAccountStart', 'OpenChartAccount',
- 'GeneralLedgerAccount', 'GeneralLedgerAccountContext',
- 'GeneralLedgerLine', 'GeneralLedgerLineContext',
- 'GeneralLedger', 'TrialBalance',
- 'BalanceSheetContext', 'BalanceSheetComparisionContext',
- 'IncomeStatementContext',
- 'AgedBalanceContext', 'AgedBalance', 'AgedBalanceReport',
- 'CreateChartStart', 'CreateChartAccount', 'CreateChartProperties',
- 'CreateChart', 'UpdateChartStart', 'UpdateChartSucceed', 'UpdateChart']
-
def inactive_records(func):
@wraps(func)
@@ -231,8 +218,8 @@
parent = fields.Many2One('account.account.type', 'Parent',
ondelete="RESTRICT",
states={
- 'readonly': (Bool(Eval('template', -1)) &
- ~Eval('template_override', False)),
+ 'readonly': (Bool(Eval('template', -1))
+ & ~Eval('template_override', False)),
},
domain=[
('company', '=', Eval('company')),
@@ -591,8 +578,8 @@
if not account or account.party_required != self.party_required:
res['party_required'] = self.party_required
if (not account
- or account.general_ledger_balance !=
- self.general_ledger_balance):
+ or account.general_ledger_balance
+ != self.general_ledger_balance):
res['general_ledger_balance'] = self.general_ledger_balance
if not account or account.template != self:
res['template'] = self.id
@@ -706,8 +693,8 @@
'Account'
__name__ = 'account.account'
_states = {
- 'readonly': (Bool(Eval('template', -1)) &
- ~Eval('template_override', False)),
+ 'readonly': (Bool(Eval('template', -1))
+ & ~Eval('template_override', False)),
}
company = fields.Many2One('company.company', 'Company', required=True,
ondelete="RESTRICT")
diff -r d7a99724f330 -r 12d40183365a fiscalyear.py
--- a/fiscalyear.py Wed Feb 12 00:19:27 2020 +0100
+++ b/fiscalyear.py Sun Mar 01 12:33:50 2020 +0100
@@ -158,8 +158,8 @@
if values.get('post_move_sequence'):
for fiscalyear in fiscalyears:
if (fiscalyear.post_move_sequence
- and fiscalyear.post_move_sequence.id !=
- values['post_move_sequence']):
+ and fiscalyear.post_move_sequence.id
+ != values['post_move_sequence']):
if Move.search([
('period.fiscalyear', '=', fiscalyear.id),
('state', '=', 'posted'),
diff -r d7a99724f330 -r 12d40183365a journal.py
--- a/journal.py Wed Feb 12 00:19:27 2020 +0100
+++ b/journal.py Sun Mar 01 12:33:50 2020 +0100
@@ -17,10 +17,6 @@
from trytond.modules.company.model import (
CompanyMultiValueMixin, CompanyValueMixin)
-__all__ = ['Journal', 'JournalSequence',
- 'JournalCashContext',
- 'JournalPeriod']
-
STATES = {
'readonly': Eval('state') == 'close',
}
diff -r d7a99724f330 -r 12d40183365a move.py
--- a/move.py Wed Feb 12 00:19:27 2020 +0100
+++ b/move.py Sun Mar 01 12:33:50 2020 +0100
@@ -30,15 +30,6 @@
ReconciliationError, DeleteDelegatedWarning, GroupLineError,
CancelDelegatedWarning)
-__all__ = ['Move', 'Reconciliation', 'Line', 'WriteOff', 'OpenJournalAsk',
- 'OpenJournal', 'OpenAccount',
- 'ReconcileLinesWriteOff', 'ReconcileLines',
- 'UnreconcileLines',
- 'Reconcile', 'ReconcileShow',
- 'CancelMoves', 'CancelMovesDefault',
- 'GroupLines', 'GroupLinesStart',
- 'PrintGeneralJournalStart', 'PrintGeneralJournal', 'GeneralJournal']
-
_MOVE_STATES = {
'readonly': Eval('state') == 'posted',
}
@@ -85,10 +76,10 @@
('account.company', '=', Eval('company', -1)),
],
states=_MOVE_STATES, depends=_MOVE_DEPENDS + ['company'],
- context={
- 'journal': Eval('journal'),
- 'period': Eval('period'),
- 'date': Eval('date'),
+ context={
+ 'journal': Eval('journal'),
+ 'period': Eval('period'),
+ 'date': Eval('date'),
})
@classmethod
@@ -443,7 +434,8 @@
move.post_number = Sequence.get_id(
move.period.post_move_sequence_used.id)
- keyfunc = lambda l: (l.party, l.account)
+ def keyfunc(l):
+ return l.party, l.account
to_reconcile = [l for l in move.lines
if ((l.debit == l.credit == Decimal('0'))
and l.account.reconcile)]
@@ -586,12 +578,12 @@
debit = fields.Numeric('Debit', digits=(16, Eval('currency_digits', 2)),
required=True, states=_states,
- depends=['currency_digits', 'credit', 'tax_lines', 'journal'] +
- _depends)
+ depends=['currency_digits', 'credit', 'tax_lines', 'journal']
+ + _depends)
credit = fields.Numeric('Credit', digits=(16, Eval('currency_digits', 2)),
required=True, states=_states,
- depends=['currency_digits', 'debit', 'tax_lines', 'journal'] +
- _depends)
+ depends=['currency_digits', 'debit', 'tax_lines', 'journal']
+ + _depends)
account = fields.Many2One('account.account', 'Account', required=True,
domain=[
('type', '!=', None),
@@ -1375,8 +1367,8 @@
def default_ask(self, fields):
JournalPeriod = Pool().get('account.journal.period')
- if (Transaction().context.get('active_model', '') ==
- 'account.journal.period'
+ if (Transaction().context.get('active_model', '')
+ == 'account.journal.period'
and Transaction().context.get('active_id')):
journal_period = JournalPeriod(Transaction().context['active_id'])
return {
@@ -1388,8 +1380,8 @@
def do_open_(self, action):
JournalPeriod = Pool().get('account.journal.period')
- if (Transaction().context.get('active_model', '') ==
- 'account.journal.period'
+ if (Transaction().context.get('active_model', '')
+ == 'account.journal.period'
and Transaction().context.get('active_id')):
journal_period = JournalPeriod(Transaction().context['active_id'])
journal = journal_period.journal
diff -r d7a99724f330 -r 12d40183365a move_template.py
--- a/move_template.py Wed Feb 12 00:19:27 2020 +0100
+++ b/move_template.py Sun Mar 01 12:33:50 2020 +0100
@@ -14,10 +14,6 @@
from trytond.pool import Pool
from trytond.tools import decistmt
-__all__ = ['MoveTemplate', 'MoveTemplateKeyword',
- 'MoveLineTemplate', 'TaxLineTemplate',
- 'CreateMove', 'CreateMoveTemplate', 'CreateMoveKeywords']
-
class MoveTemplate(DeactivableMixin, ModelSQL, ModelView):
'Account Move Template'
diff -r d7a99724f330 -r 12d40183365a party.py
--- a/party.py Wed Feb 12 00:19:27 2020 +0100
+++ b/party.py Sun Mar 01 12:33:50 2020 +0100
@@ -20,7 +20,6 @@
from .exceptions import AccountMissing
-__all__ = ['Party', 'PartyAccount', 'PartyReplace', 'PartyErase']
account_names = [
'account_payable', 'account_receivable',
'customer_tax_rule', 'supplier_tax_rule']
diff -r d7a99724f330 -r 12d40183365a period.py
--- a/period.py Wed Feb 12 00:19:27 2020 +0100
+++ b/period.py Sun Mar 01 12:33:50 2020 +0100
@@ -12,8 +12,6 @@
from .exceptions import (PeriodNotFoundError, ClosePeriodError,
PeriodDatesError, PeriodSequenceError)
-__all__ = ['Period']
-
_STATES = {
'readonly': Eval('state') != 'open',
}
@@ -212,7 +210,8 @@
i = 0
while i < len(args):
# add test for xmlrpc and pyson that doesn't handle tuple
- if ((isinstance(args[i], tuple)
+ if ((
+ isinstance(args[i], tuple)
or (isinstance(args[i], list) and len(args[i]) > 2
and args[i][1] in OPERATORS))
and args[i][0] in ('start_date', 'end_date')
@@ -272,8 +271,8 @@
if values.get('post_move_sequence'):
for period in periods:
if (period.post_move_sequence
- and period.post_move_sequence.id !=
- values['post_move_sequence']):
+ and period.post_move_sequence.id
+ != values['post_move_sequence']):
if Move.search([
('period', '=', period.id),
('state', '=', 'posted'),
diff -r d7a99724f330 -r 12d40183365a setup.py
--- a/setup.py Wed Feb 12 00:19:27 2020 +0100
+++ b/setup.py Sun Mar 01 12:33:50 2020 +0100
@@ -79,8 +79,8 @@
keywords='tryton account',
package_dir={'trytond.modules.account': '.'},
packages=(
- ['trytond.modules.account'] +
- ['trytond.modules.account.%s' % p for p in find_packages()]
+ ['trytond.modules.account']
+ + ['trytond.modules.account.%s' % p for p in find_packages()]
),
package_data={
'trytond.modules.account': (info.get('xml', [])
@@ -94,7 +94,8 @@
'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 -r d7a99724f330 -r 12d40183365a tax.py
--- a/tax.py Wed Feb 12 00:19:27 2020 +0100
+++ b/tax.py Sun Mar 01 12:33:50 2020 +0100
@@ -23,14 +23,6 @@
from .common import PeriodMixin, ActivePeriodMixin
-__all__ = ['TaxGroup', 'TaxCodeTemplate', 'TaxCode',
- 'TaxCodeLineTemplate', 'TaxCodeLine',
- 'OpenChartTaxCodeStart', 'OpenChartTaxCode',
- 'TaxTemplate', 'Tax', 'TaxLine', 'TaxRuleTemplate', 'TaxRule',
- 'TaxRuleLineTemplate', 'TaxRuleLine',
- 'OpenTaxCode',
- 'TestTax', 'TestTaxView', 'TestTaxViewResult']
-
KINDS = [
('sale', 'Sale'),
('purchase', 'Purchase'),
@@ -1026,8 +1018,8 @@
vals = child.template._get_tax_value(tax=child)
invoice_account_id = (child.invoice_account.id
if child.invoice_account else None)
- if (child.template.invoice_account and
- invoice_account_id != template2account.get(
+ if (child.template.invoice_account
+ and invoice_account_id != template2account.get(
child.template.invoice_account.id)):
vals['invoice_account'] = template2account.get(
child.template.invoice_account.id)
@@ -1036,8 +1028,9 @@
vals['invoice_account'] = None
credit_note_account_id = (child.credit_note_account.id
if child.credit_note_account else None)
- if (child.template.credit_note_account and
- credit_note_account_id != template2account.get(
+ if (child.template.credit_note_account
+ and credit_note_account_id
+ != template2account.get(
child.template.credit_note_account.id)):
vals['credit_note_account'] = template2account.get(
child.template.credit_note_account.id)
@@ -1431,8 +1424,8 @@
('group', '=', None),
If(Eval('_parent_rule', {}).get('kind', 'both') == 'sale',
('group.kind', 'in', ['sale', 'both']),
- If(Eval('_parent_rule', {}).get('kind', 'both') ==
- 'purchase',
+ If(Eval('_parent_rule', {}).get('kind', 'both')
+ == 'purchase',
('group.kind', 'in', ['purchase', 'both']),
('group.kind', 'in', ['sale', 'purchase', 'both']))),
],
@@ -1452,8 +1445,8 @@
('group', '=', None),
If(Eval('_parent_rule', {}).get('kind', 'both') == 'sale',
('group.kind', 'in', ['sale', 'both']),
- If(Eval('_parent_rule', {}).get('kind', 'both') ==
- 'purchase',
+ If(Eval('_parent_rule', {}).get('kind', 'both')
+ == 'purchase',
('group.kind', 'in', ['purchase', 'both']),
('group.kind', 'in', ['sale', 'purchase', 'both']))),
],
@@ -1545,8 +1538,8 @@
('group', '=', None),
If(Eval('_parent_rule', {}).get('kind', 'both') == 'sale',
('group.kind', 'in', ['sale', 'both']),
- If(Eval('_parent_rule', {}).get('kind', 'both') ==
- 'purchase',
+ If(Eval('_parent_rule', {}).get('kind', 'both')
+ == 'purchase',
('group.kind', 'in', ['purchase', 'both']),
('group.kind', 'in', ['sale', 'purchase', 'both']))),
],
@@ -1566,8 +1559,8 @@
('group', '=', None),
If(Eval('_parent_rule', {}).get('kind', 'both') == 'sale',
('group.kind', 'in', ['sale', 'both']),
- If(Eval('_parent_rule', {}).get('kind', 'both') ==
- 'purchase',
+ If(Eval('_parent_rule', {}).get('kind', 'both')
+ == 'purchase',
('group.kind', 'in', ['purchase', 'both']),
('group.kind', 'in', ['sale', 'purchase', 'both']))),
],
@@ -1645,8 +1638,8 @@
vals['rule'] = template2rule[line.template.rule.id]
if line.origin_tax:
if line.template.origin_tax:
- if (line.origin_tax.id !=
- template2tax[line.template.origin_tax.id]):
+ if (line.origin_tax.id
+ != template2tax[line.template.origin_tax.id]):
vals['origin_tax'] = template2tax[
line.template.origin_tax.id]
else: