changeset ef358f45f33f in modules/web_user:default
details: https://hg.tryton.org/modules/web_user?cmd=changeset;node=ef358f45f33f
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 |  16 ++++++++--------
 party.py    |  10 ++++------
 setup.py    |   7 ++++---
 user.py     |   5 ++---
 5 files changed, 20 insertions(+), 20 deletions(-)

diffs (126 lines):

diff -r 9a032e4a0f0c -r ef358f45f33f .flake8
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/.flake8   Sun Mar 01 12:33:54 2020 +0100
@@ -0,0 +1,2 @@
+[flake8]
+ignore=E123,E124,E126,E128,W503
diff -r 9a032e4a0f0c -r ef358f45f33f __init__.py
--- a/__init__.py       Tue Jan 21 00:36:34 2020 +0100
+++ b/__init__.py       Sun Mar 01 12:33:54 2020 +0100
@@ -2,21 +2,21 @@
 # this repository contains the full copyright notices and license terms.
 
 from trytond.pool import Pool
-from .user import *
+from . import user
 from . import party
 
 
 def register():
     Pool.register(
-        User,
-        UserAuthenticateAttempt,
-        UserSession,
+        user.User,
+        user.UserAuthenticateAttempt,
+        user.UserSession,
         module='web_user', type_='model')
     Pool.register(
-        party.PartyReplace,
-        party.PartyErase,
+        party.Replace,
+        party.Erase,
         module='web_user', type_='wizard')
     Pool.register(
-        EmailValidation,
-        EmailResetPassword,
+        user.EmailValidation,
+        user.EmailResetPassword,
         module='web_user', type_='report')
diff -r 9a032e4a0f0c -r ef358f45f33f party.py
--- a/party.py  Tue Jan 21 00:36:34 2020 +0100
+++ b/party.py  Sun Mar 01 12:33:54 2020 +0100
@@ -2,26 +2,24 @@
 # this repository contains the full copyright notices and license terms.
 from trytond.pool import PoolMeta, Pool
 
-__all__ = ['PartyReplace', 'PartyErase']
 
-
-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() + [
             ('web.user', 'party'),
             ]
 
 
-class PartyErase(metaclass=PoolMeta):
+class Erase(metaclass=PoolMeta):
     __name__ = 'party.erase'
 
     def to_erase(self, party_id):
         pool = Pool()
         User = pool.get('web.user')
-        to_erase = super(PartyErase, self).to_erase(party_id)
+        to_erase = super().to_erase(party_id)
         to_erase.append(
             (User, [('party', '=', party_id)], True,
                 ['email'],
diff -r 9a032e4a0f0c -r ef358f45f33f setup.py
--- a/setup.py  Tue Jan 21 00:36:34 2020 +0100
+++ b/setup.py  Sun Mar 01 12:33:54 2020 +0100
@@ -79,8 +79,8 @@
     keywords='web user',
     package_dir={'trytond.modules.web_user': '.'},
     packages=(
-        ['trytond.modules.web_user'] +
-        ['trytond.modules.web_user.%s' % p for p in find_packages()]
+        ['trytond.modules.web_user']
+        + ['trytond.modules.web_user.%s' % p for p in find_packages()]
         ),
     package_data={
         'trytond.modules.web_user': (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 :: Czech',
diff -r 9a032e4a0f0c -r ef358f45f33f user.py
--- a/user.py   Tue Jan 21 00:36:34 2020 +0100
+++ b/user.py   Sun Mar 01 12:33:54 2020 +0100
@@ -18,6 +18,7 @@
     import html2text
 except ImportError:
     html2text = None
+from sql import Literal
 from sql.conditionals import Coalesce
 from sql.functions import CurrentTimestamp
 from sql.operators import Equal
@@ -35,8 +36,6 @@
 from trytond.ir.session import token_hex
 from trytond.res.user import LoginAttempt, CRYPT_CONTEXT
 
-__all__ = ['User', 'UserAuthenticateAttempt', 'UserSession',
-    'EmailValidation', 'EmailResetPassword']
 logger = logging.getLogger(__name__)
 
 
@@ -92,7 +91,7 @@
         cls._sql_constraints += [
             ('email_exclude',
                 Exclude(table, (table.email, Equal),
-                    where=table.active == True),
+                    where=table.active == Literal(True)),
                 'web_user.msg_user_email_unique'),
             ]
         cls._buttons.update({

Reply via email to