changeset fddd322cc800 in modules/party:default
details: https://hg.tryton.org/modules/party?cmd=changeset;node=fddd322cc800
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          |  10 +++++-----
 address.py           |   3 ++-
 category.py          |   2 --
 configuration.py     |   2 --
 contact_mechanism.py |   2 --
 party.py             |  23 +++++++++--------------
 setup.py             |   7 ++++---
 8 files changed, 22 insertions(+), 29 deletions(-)

diffs (201 lines):

diff -r 84cb9d35b4b1 -r fddd322cc800 .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 84cb9d35b4b1 -r fddd322cc800 __init__.py
--- a/__init__.py       Sun Feb 23 13:56:58 2020 +0100
+++ b/__init__.py       Sun Mar 01 12:33:52 2020 +0100
@@ -15,10 +15,10 @@
         party.Party,
         party.PartyLang,
         party.PartyCategory,
-        party.PartyIdentifier,
+        party.Identifier,
         party.CheckVIESResult,
-        party.PartyReplaceAsk,
-        party.PartyEraseAsk,
+        party.ReplaceAsk,
+        party.EraseAsk,
         address.Address,
         address.AddressFormat,
         address.SubdivisionType,
@@ -29,6 +29,6 @@
         module='party', type_='model')
     Pool.register(
         party.CheckVIES,
-        party.PartyReplace,
-        party.PartyErase,
+        party.Replace,
+        party.Erase,
         module='party', type_='wizard')
diff -r 84cb9d35b4b1 -r fddd322cc800 address.py
--- a/address.py        Sun Feb 23 13:56:58 2020 +0100
+++ b/address.py        Sun Mar 01 12:33:52 2020 +0100
@@ -3,6 +3,7 @@
 'Address'
 from string import Template
 
+from sql import Literal
 from sql.conditionals import Coalesce
 from sql.functions import Substring
 from sql.operators import Concat, Equal
@@ -384,7 +385,7 @@
         cls._sql_constraints = [
             ('country_code_unique',
                 Exclude(t, (t.country_code, Equal),
-                    where=t.active == True),
+                    where=t.active == Literal(True)),
                 'party.msg_address_subdivision_country_code_unique')
             ]
         cls._order.insert(0, ('country_code', 'ASC NULLS LAST'))
diff -r 84cb9d35b4b1 -r fddd322cc800 category.py
--- a/category.py       Sun Feb 23 13:56:58 2020 +0100
+++ b/category.py       Sun Mar 01 12:33:52 2020 +0100
@@ -7,8 +7,6 @@
     ModelView, ModelSQL, DeactivableMixin, fields, Exclude, tree)
 from trytond.pyson import Eval
 
-__all__ = ['Category']
-
 STATES = {
     'readonly': ~Eval('active'),
 }
diff -r 84cb9d35b4b1 -r fddd322cc800 configuration.py
--- a/configuration.py  Sun Feb 23 13:56:58 2020 +0100
+++ b/configuration.py  Sun Mar 01 12:33:52 2020 +0100
@@ -6,8 +6,6 @@
 from trytond.pool import Pool
 from trytond.tools.multivalue import migrate_property
 
-__all__ = ['Configuration', 'ConfigurationSequence', 'ConfigurationLang']
-
 party_sequence = fields.Many2One('ir.sequence', 'Party Sequence',
     domain=[
         ('code', '=', 'party.party'),
diff -r 84cb9d35b4b1 -r fddd322cc800 contact_mechanism.py
--- a/contact_mechanism.py      Sun Feb 23 13:56:58 2020 +0100
+++ b/contact_mechanism.py      Sun Mar 01 12:33:52 2020 +0100
@@ -14,8 +14,6 @@
 from trytond.pyson import Eval
 from .exceptions import InvalidPhoneNumber
 
-__all__ = ['ContactMechanism']
-
 STATES = {
     'readonly': ~Eval('active'),
     }
diff -r 84cb9d35b4b1 -r fddd322cc800 party.py
--- a/party.py  Sun Feb 23 13:56:58 2020 +0100
+++ b/party.py  Sun Mar 01 12:33:52 2020 +0100
@@ -18,11 +18,6 @@
 from .exceptions import (
     InvalidIdentifierCode, VIESUnavailable, SimilarityWarning, EraseError)
 
-__all__ = ['Party', 'PartyLang', 'PartyCategory', 'PartyIdentifier',
-    'CheckVIESResult', 'CheckVIES',
-    'PartyReplace', 'PartyReplaceAsk',
-    'PartyErase', 'PartyEraseAsk']
-
 STATES = {
     'readonly': ~Eval('active', True),
 }
@@ -315,7 +310,7 @@
         ondelete='CASCADE', required=True, select=True)
 
 
-class PartyIdentifier(sequence_ordered(), ModelSQL, ModelView):
+class Identifier(sequence_ordered(), ModelSQL, ModelView):
     'Party Identifier'
     __name__ = 'party.identifier'
     _rec_name = 'code'
@@ -441,7 +436,7 @@
         cursor = Transaction().connection.cursor()
         party = Party.__table__()
 
-        super(PartyIdentifier, cls).__register__(module_name)
+        super().__register__(module_name)
 
         party_h = Party.__table_handler__(module_name)
         if (party_h.column_exist('vat_number')
@@ -479,7 +474,7 @@
         return self.code
 
     def pre_validate(self):
-        super(PartyIdentifier, self).pre_validate()
+        super().pre_validate()
         self.check_code()
 
     @fields.depends('type', 'party', 'code')
@@ -563,7 +558,7 @@
             }
 
 
-class PartyReplace(Wizard):
+class Replace(Wizard):
     "Replace Party"
     __name__ = 'party.replace'
     start_state = 'ask'
@@ -654,7 +649,7 @@
             ]
 
 
-class PartyReplaceAsk(ModelView):
+class ReplaceAsk(ModelView):
     "Replace Party"
     __name__ = 'party.replace.ask'
     source = fields.Many2One('party.party', "Source", required=True,
@@ -678,7 +673,7 @@
             self.destination = self.source.replaced_by
 
 
-class PartyErase(Wizard):
+class Erase(Wizard):
     "Erase Party"
     __name__ = 'party.erase'
     start_state = 'ask'
@@ -753,8 +748,8 @@
                                         Model.__name__ + ',%')
                                     & Model.id.sql_cast(
                                         Substring(table.resource,
-                                            Position(',', table.resource) +
-                                            Literal(1))).in_(query)))
+                                            Position(',', table.resource)
+                                            + Literal(1))).in_(query)))
         return 'end'
 
     def check_erase(self, party):
@@ -791,7 +786,7 @@
         return [Attachment, Note]
 
 
-class PartyEraseAsk(ModelView):
+class EraseAsk(ModelView):
     "Erase Party"
     __name__ = 'party.erase.ask'
     party = fields.Many2One('party.party', "Party", required=True,
diff -r 84cb9d35b4b1 -r fddd322cc800 setup.py
--- a/setup.py  Sun Feb 23 13:56:58 2020 +0100
+++ b/setup.py  Sun Mar 01 12:33:52 2020 +0100
@@ -79,8 +79,8 @@
     keywords='tryton party',
     package_dir={'trytond.modules.party': '.'},
     packages=(
-        ['trytond.modules.party'] +
-        ['trytond.modules.party.%s' % p for p in find_packages()]
+        ['trytond.modules.party']
+        + ['trytond.modules.party.%s' % p for p in find_packages()]
         ),
     package_data={
         'trytond.modules.party': (info.get('xml', [])
@@ -95,7 +95,8 @@
         'Intended Audience :: Financial and Insurance Industry',
         'Intended Audience :: Legal Industry',
         'Intended Audience :: Manufacturing',
-        '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)',

Reply via email to