changeset 4e47da741b82 in modules/sale_opportunity:default
details: 
https://hg.tryton.org/modules/sale_opportunity?cmd=changeset;node=4e47da741b82
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       |  50 +++++++++++++++++++++++++-------------------------
 account.py        |   2 --
 company.py        |   2 --
 configuration.py  |   2 --
 opportunity.py    |  23 ++++++++++++++---------
 party.py          |   6 ++----
 product.py        |   2 --
 sale.py           |   2 --
 setup.py          |   7 ++++---
 tests/__init__.py |   2 +-
 11 files changed, 48 insertions(+), 52 deletions(-)

diffs (239 lines):

diff -r 91b87bd63e29 -r 4e47da741b82 .flake8
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/.flake8   Sun Mar 01 12:33:53 2020 +0100
@@ -0,0 +1,2 @@
+[flake8]
+ignore=E123,E124,E126,E128,W503
diff -r 91b87bd63e29 -r 4e47da741b82 __init__.py
--- a/__init__.py       Sat Jan 25 20:18:49 2020 +0100
+++ b/__init__.py       Sun Mar 01 12:33:53 2020 +0100
@@ -2,35 +2,35 @@
 # this repository contains the full copyright notices and license terms.
 
 from trytond.pool import Pool
-from .opportunity import *
-from .configuration import *
-from .sale import *
-from .party import *
-from .account import *
-from .product import *
-from .company import *
+from . import opportunity
+from . import configuration
+from . import sale
+from . import party
+from . import account
+from . import product
+from . import company
 
 
 def register():
     Pool.register(
-        SaleOpportunity,
-        SaleOpportunityLine,
-        SaleOpportunityEmployee,
-        SaleOpportunityEmployeeContext,
-        SaleOpportunityMonthly,
-        SaleOpportunityEmployeeMonthly,
-        Configuration,
-        ConfigurationSequence,
-        Sale,
-        Party,
-        Address,
-        PaymentTerm,
-        PaymentTermLine,
-        Template,
-        Product,
-        Company,
-        Employee,
+        opportunity.SaleOpportunity,
+        opportunity.SaleOpportunityLine,
+        opportunity.SaleOpportunityEmployee,
+        opportunity.SaleOpportunityEmployeeContext,
+        opportunity.SaleOpportunityMonthly,
+        opportunity.SaleOpportunityEmployeeMonthly,
+        configuration.Configuration,
+        configuration.ConfigurationSequence,
+        sale.Sale,
+        party.Party,
+        party.Address,
+        account.PaymentTerm,
+        account.PaymentTermLine,
+        product.Template,
+        product.Product,
+        company.Company,
+        company.Employee,
         module='sale_opportunity', type_='model')
     Pool.register(
-        PartyReplace,
+        party.Replace,
         module='sale_opportunity', type_='wizard')
diff -r 91b87bd63e29 -r 4e47da741b82 account.py
--- a/account.py        Sat Jan 25 20:18:49 2020 +0100
+++ b/account.py        Sun Mar 01 12:33:53 2020 +0100
@@ -2,8 +2,6 @@
 # this repository contains the full copyright notices and license terms.
 from trytond.pool import PoolMeta
 
-__all__ = ['PaymentTerm', 'PaymentTermLine']
-
 
 class PaymentTerm(metaclass=PoolMeta):
     __name__ = 'account.invoice.payment_term'
diff -r 91b87bd63e29 -r 4e47da741b82 company.py
--- a/company.py        Sat Jan 25 20:18:49 2020 +0100
+++ b/company.py        Sun Mar 01 12:33:53 2020 +0100
@@ -2,8 +2,6 @@
 # this repository contains the full copyright notices and license terms.
 from trytond.pool import PoolMeta
 
-__all__ = ['Company', 'Employee']
-
 
 class Company(metaclass=PoolMeta):
     __name__ = 'company.company'
diff -r 91b87bd63e29 -r 4e47da741b82 configuration.py
--- a/configuration.py  Sat Jan 25 20:18:49 2020 +0100
+++ b/configuration.py  Sun Mar 01 12:33:53 2020 +0100
@@ -5,8 +5,6 @@
 from trytond.pyson import Eval
 from trytond.pool import PoolMeta, Pool
 
-__all__ = ['Configuration', 'ConfigurationSequence']
-
 
 class Configuration(metaclass=PoolMeta):
     'Sale Configuration'
diff -r 91b87bd63e29 -r 4e47da741b82 opportunity.py
--- a/opportunity.py    Sat Jan 25 20:18:49 2020 +0100
+++ b/opportunity.py    Sun Mar 01 12:33:53 2020 +0100
@@ -614,17 +614,22 @@
             Max(opportunity.write_date).as_('write_date'),
             opportunity.company,
             Count(Literal(1)).as_('number'),
-            Sum(Case((opportunity.state.in_(cls._converted_state()),
+            Sum(Case(
+                    (opportunity.state.in_(cls._converted_state()),
                         Literal(1)), else_=Literal(0))).as_('converted'),
-            Sum(Case((opportunity.state.in_(cls._won_state()),
+            Sum(Case(
+                    (opportunity.state.in_(cls._won_state()),
                         Literal(1)), else_=Literal(0))).as_('won'),
-            Sum(Case((opportunity.state.in_(cls._lost_state()),
+            Sum(Case(
+                    (opportunity.state.in_(cls._lost_state()),
                         Literal(1)), else_=Literal(0))).as_('lost'),
             Sum(opportunity.amount).as_('amount'),
-            Sum(Case((opportunity.state.in_(cls._converted_state()),
+            Sum(Case(
+                    (opportunity.state.in_(cls._converted_state()),
                         opportunity.amount),
                     else_=Literal(0))).as_('converted_amount'),
-            Sum(Case((opportunity.state.in_(cls._won_state()),
+            Sum(Case(
+                    (opportunity.state.in_(cls._won_state()),
                         opportunity.amount),
                     else_=Literal(0))).as_('won_amount'))
 
@@ -644,11 +649,11 @@
             )
         where = Literal(True)
         if Transaction().context.get('start_date'):
-            where &= (opportunity.start_date >=
-                Transaction().context['start_date'])
+            where &= (opportunity.start_date
+                >= Transaction().context['start_date'])
         if Transaction().context.get('end_date'):
-            where &= (opportunity.start_date <=
-                Transaction().context['end_date'])
+            where &= (opportunity.start_date
+                <= Transaction().context['end_date'])
         query.where = where
         query.group_by = (opportunity.employee, opportunity.company)
         return query
diff -r 91b87bd63e29 -r 4e47da741b82 party.py
--- a/party.py  Sat Jan 25 20:18:49 2020 +0100
+++ b/party.py  Sun Mar 01 12:33:53 2020 +0100
@@ -2,8 +2,6 @@
 # this repository contains the full copyright notices and license terms.
 from trytond.pool import PoolMeta
 
-__all__ = ['Party', 'Address', 'PartyReplace']
-
 
 class Party(metaclass=PoolMeta):
     __name__ = 'party.party'
@@ -15,11 +13,11 @@
     _history = True
 
 
-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() + [
             ('sale.opportunity', 'party'),
             ]
diff -r 91b87bd63e29 -r 4e47da741b82 product.py
--- a/product.py        Sat Jan 25 20:18:49 2020 +0100
+++ b/product.py        Sun Mar 01 12:33:53 2020 +0100
@@ -2,8 +2,6 @@
 # this repository contains the full copyright notices and license terms.
 from trytond.pool import PoolMeta
 
-__all__ = ['Template', 'Product']
-
 
 class Template(metaclass=PoolMeta):
     __name__ = 'product.template'
diff -r 91b87bd63e29 -r 4e47da741b82 sale.py
--- a/sale.py   Sat Jan 25 20:18:49 2020 +0100
+++ b/sale.py   Sun Mar 01 12:33:53 2020 +0100
@@ -5,8 +5,6 @@
 from trytond.pool import PoolMeta, Pool
 from trytond.transaction import Transaction
 
-__all__ = ['Sale']
-
 
 def process_opportunity(func):
     @wraps(func)
diff -r 91b87bd63e29 -r 4e47da741b82 setup.py
--- a/setup.py  Sat Jan 25 20:18:49 2020 +0100
+++ b/setup.py  Sun Mar 01 12:33:53 2020 +0100
@@ -79,8 +79,8 @@
     keywords='tryton sale opportunity',
     package_dir={'trytond.modules.sale_opportunity': '.'},
     packages=(
-        ['trytond.modules.sale_opportunity'] +
-        ['trytond.modules.sale_opportunity.%s' % p for p in find_packages()]
+        ['trytond.modules.sale_opportunity']
+        + ['trytond.modules.sale_opportunity.%s' % p for p in find_packages()]
         ),
     package_data={
         'trytond.modules.sale_opportunity': (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 91b87bd63e29 -r 4e47da741b82 tests/__init__.py
--- a/tests/__init__.py Sat Jan 25 20:18:49 2020 +0100
+++ b/tests/__init__.py Sun Mar 01 12:33:53 2020 +0100
@@ -2,7 +2,7 @@
 # this repository contains the full copyright notices and license terms.
 
 try:
-    from trytond.modules.sale_opportunity.tests.test_sale_opportunity import 
suite
+    from trytond.modules.sale_opportunity.tests.test_sale_opportunity import 
suite  # noqa: E501
 except ImportError:
     from .test_sale_opportunity import suite
 

Reply via email to