changeset 1e9c1917a650 in modules/analytic_account:default
details: 
https://hg.tryton.org/modules/analytic_account?cmd=changeset;node=1e9c1917a650
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 ++
 __init__.py       |  25 ++++++++++++++-----------
 account.py        |  12 ++++--------
 line.py           |   2 --
 rule.py           |   2 --
 setup.py          |   7 ++++---
 tests/__init__.py |   2 +-
 7 files changed, 25 insertions(+), 27 deletions(-)

diffs (157 lines):

diff -r 49fa589a7bd4 -r 1e9c1917a650 .flake8
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/.flake8   Sun Mar 01 12:33:52 2020 +0100
@@ -0,0 +1,2 @@
+[flake8]
+ignore=E123,E124,E126,E128,W503
diff -r 49fa589a7bd4 -r 1e9c1917a650 __init__.py
--- a/__init__.py       Sat Dec 28 18:16:28 2019 +0100
+++ b/__init__.py       Sun Mar 01 12:33:52 2020 +0100
@@ -2,23 +2,26 @@
 # this repository contains the full copyright notices and license terms.
 
 from trytond.pool import Pool
-from .account import *
-from .line import *
+from . import account
+from . import line
 from . import rule
+from .account import AnalyticMixin
+
+__all__ = [AnalyticMixin]
 
 
 def register():
     Pool.register(
-        Account,
-        AccountDistribution,
-        OpenChartAccountStart,
-        AnalyticAccountEntry,
-        Line,
-        Move,
-        MoveLine,
+        account.Account,
+        account.AccountDistribution,
+        account.OpenChartAccountStart,
+        account.AnalyticAccountEntry,
+        line.Line,
+        line.Move,
+        line.MoveLine,
         rule.Rule,
         module='analytic_account', type_='model')
     Pool.register(
-        OpenChartAccount,
-        OpenAccount,
+        account.OpenChartAccount,
+        line.OpenAccount,
         module='analytic_account', type_='wizard')
diff -r 49fa589a7bd4 -r 1e9c1917a650 account.py
--- a/account.py        Sat Dec 28 18:16:28 2019 +0100
+++ b/account.py        Sun Mar 01 12:33:52 2020 +0100
@@ -3,7 +3,7 @@
 from decimal import Decimal
 from collections import defaultdict
 
-from sql import Column
+from sql import Column, Literal, Null
 from sql.aggregate import Sum
 from sql.conditionals import Coalesce
 
@@ -18,10 +18,6 @@
 
 from .exceptions import AccountValidationError
 
-__all__ = ['Account', 'AccountDistribution',
-    'OpenChartAccountStart', 'OpenChartAccount',
-    'AnalyticAccountEntry', 'AnalyticMixin']
-
 
 class Account(
         DeactivableMixin, tree('distribution_parents'), tree(),
@@ -191,7 +187,7 @@
                 Sum(Coalesce(line.credit, 0) - Coalesce(line.debit, 0)),
                 where=(table.type != 'view')
                 & table.id.in_(all_ids)
-                & (table.active == True) & line_query,
+                & (table.active == Literal(True)) & line_query,
                 group_by=table.id))
         account_sum = defaultdict(Decimal)
         for account_id, value in cursor.fetchall():
@@ -245,7 +241,7 @@
                 ).select(*columns,
                 where=(table.type != 'view')
                 & table.id.in_(ids)
-                & (table.active == True) & line_query,
+                & (table.active == Literal(True)) & line_query,
                 group_by=table.id))
 
         for row in cursor.fetchall():
@@ -486,7 +482,7 @@
             entry = AccountEntry.__table__()
             table = cls.__table__()
             cursor.execute(*table.select(table.id, table.analytic_accounts,
-                    where=table.analytic_accounts != None))
+                    where=table.analytic_accounts != Null))
             for line_id, selection_id in cursor.fetchall():
                 cursor.execute(*entry.update(
                         columns=[entry.origin],
diff -r 49fa589a7bd4 -r 1e9c1917a650 line.py
--- a/line.py   Sat Dec 28 18:16:28 2019 +0100
+++ b/line.py   Sun Mar 01 12:33:52 2020 +0100
@@ -11,8 +11,6 @@
 from trytond.transaction import Transaction
 from trytond.pool import Pool, PoolMeta
 
-__all__ = ['Line', 'Move', 'MoveLine', 'OpenAccount']
-
 
 class Line(ModelSQL, ModelView):
     'Analytic Line'
diff -r 49fa589a7bd4 -r 1e9c1917a650 rule.py
--- a/rule.py   Sat Dec 28 18:16:28 2019 +0100
+++ b/rule.py   Sun Mar 01 12:33:52 2020 +0100
@@ -7,8 +7,6 @@
 
 from .account import AnalyticMixin
 
-__all__ = ['Rule']
-
 
 class Rule(sequence_ordered(), MatchMixin, AnalyticMixin, ModelSQL, ModelView):
     "Analytic Rule"
diff -r 49fa589a7bd4 -r 1e9c1917a650 setup.py
--- a/setup.py  Sat Dec 28 18:16:28 2019 +0100
+++ b/setup.py  Sun Mar 01 12:33:52 2020 +0100
@@ -79,8 +79,8 @@
     keywords='tryton analytic account',
     package_dir={'trytond.modules.analytic_account': '.'},
     packages=(
-        ['trytond.modules.analytic_account'] +
-        ['trytond.modules.analytic_account.%s' % p for p in find_packages()]
+        ['trytond.modules.analytic_account']
+        + ['trytond.modules.analytic_account.%s' % p for p in find_packages()]
         ),
     package_data={
         'trytond.modules.analytic_account': (info.get('xml', [])
@@ -93,7 +93,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 49fa589a7bd4 -r 1e9c1917a650 tests/__init__.py
--- a/tests/__init__.py Sat Dec 28 18:16:28 2019 +0100
+++ b/tests/__init__.py Sun Mar 01 12:33:52 2020 +0100
@@ -2,7 +2,7 @@
 # this repository contains the full copyright notices and license terms.
 
 try:
-    from trytond.modules.analytic_account.tests.test_analytic_account import 
suite
+    from trytond.modules.analytic_account.tests.test_analytic_account import 
suite  # noqa: E501
 except ImportError:
     from .test_analytic_account import suite
 

Reply via email to