changeset 1021f2b72c71 in modules/purchase:default
details: https://hg.tryton.org/modules/purchase?cmd=changeset;node=1021f2b72c71
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      |  64 ++++++++++++++++++++++++++++----------------------------
 configuration.py |   2 -
 invoice.py       |   2 -
 product.py       |   2 -
 purchase.py      |  19 ++++++++-------
 setup.py         |   7 +++--
 stock.py         |   2 -
 8 files changed, 48 insertions(+), 52 deletions(-)

diffs (236 lines):

diff -r 679a8434cbc8 -r 1021f2b72c71 .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 679a8434cbc8 -r 1021f2b72c71 __init__.py
--- a/__init__.py       Sun Feb 23 13:56:58 2020 +0100
+++ b/__init__.py       Sun Mar 01 12:33:53 2020 +0100
@@ -2,49 +2,49 @@
 # this repository contains the full copyright notices and license terms.
 
 from trytond.pool import Pool
-from .purchase import *
-from .product import *
-from .stock import *
-from .configuration import *
-from .invoice import *
+from . import purchase
+from . import product
+from . import stock
+from . import configuration
+from . import invoice
 from . import party
 
 
 def register():
     Pool.register(
-        Move,
-        Purchase,
-        PurchaseIgnoredInvoice,
-        PurchaseRecreatedInvoice,
-        PurchaseLine,
-        PurchaseLineTax,
-        PurchaseLineIgnoredMove,
-        PurchaseLineRecreatedMove,
-        Template,
-        Product,
-        ProductSupplier,
-        ProductSupplierPrice,
-        ShipmentIn,
-        ShipmentInReturn,
-        HandleShipmentExceptionAsk,
-        HandleInvoiceExceptionAsk,
-        Configuration,
-        ConfigurationSequence,
-        ConfigurationPurchaseMethod,
-        Invoice,
-        InvoiceLine,
-        Location,
+        stock.Move,
+        purchase.Purchase,
+        purchase.PurchaseIgnoredInvoice,
+        purchase.PurchaseRecreatedInvoice,
+        purchase.Line,
+        purchase.LineTax,
+        purchase.LineIgnoredMove,
+        purchase.LineRecreatedMove,
+        product.Template,
+        product.Product,
+        product.ProductSupplier,
+        product.ProductSupplierPrice,
+        stock.ShipmentIn,
+        stock.ShipmentInReturn,
+        purchase.HandleShipmentExceptionAsk,
+        purchase.HandleInvoiceExceptionAsk,
+        configuration.Configuration,
+        configuration.ConfigurationSequence,
+        configuration.ConfigurationPurchaseMethod,
+        invoice.Invoice,
+        invoice.InvoiceLine,
+        stock.Location,
         party.Party,
         party.CustomerCode,
         module='purchase', type_='model')
     Pool.register(
-        PurchaseReport,
+        purchase.PurchaseReport,
         module='purchase', type_='report')
     Pool.register(
-        OpenSupplier,
-        HandleShipmentException,
-        HandleInvoiceException,
+        purchase.OpenSupplier,
+        purchase.HandleShipmentException,
+        purchase.HandleInvoiceException,
         party.PartyReplace,
         party.PartyErase,
-        ModifyHeader,
+        purchase.ModifyHeader,
         module='purchase', type_='wizard')
diff -r 679a8434cbc8 -r 1021f2b72c71 configuration.py
--- a/configuration.py  Sun Feb 23 13:56:58 2020 +0100
+++ b/configuration.py  Sun Mar 01 12:33:53 2020 +0100
@@ -9,8 +9,6 @@
 from trytond.modules.company.model import (
     CompanyMultiValueMixin, CompanyValueMixin)
 
-__all__ = ['Configuration',
-    'ConfigurationSequence', 'ConfigurationPurchaseMethod']
 purchase_invoice_method = fields.Selection(
     'get_purchase_invoice_method', "Invoice Method")
 
diff -r 679a8434cbc8 -r 1021f2b72c71 invoice.py
--- a/invoice.py        Sun Feb 23 13:56:58 2020 +0100
+++ b/invoice.py        Sun Mar 01 12:33:53 2020 +0100
@@ -8,8 +8,6 @@
 from trytond.pool import Pool, PoolMeta
 from trytond.transaction import Transaction
 
-__all__ = ['Invoice', 'InvoiceLine']
-
 
 def process_purchase(func):
     @wraps(func)
diff -r 679a8434cbc8 -r 1021f2b72c71 product.py
--- a/product.py        Sun Feb 23 13:56:58 2020 +0100
+++ b/product.py        Sun Mar 01 12:33:53 2020 +0100
@@ -17,8 +17,6 @@
 
 from .exceptions import PurchaseUOMWarning
 
-__all__ = ['Template', 'Product', 'ProductSupplier', 'ProductSupplierPrice']
-
 
 class Template(metaclass=PoolMeta):
     __name__ = "product.template"
diff -r 679a8434cbc8 -r 1021f2b72c71 purchase.py
--- a/purchase.py       Sun Feb 23 13:56:58 2020 +0100
+++ b/purchase.py       Sun Mar 01 12:33:53 2020 +0100
@@ -299,8 +299,9 @@
             sub_query = sql_table.join(purchase_line,
                 condition=purchase_line.purchase == sql_table.id
                 ).join(invoice_line, 'LEFT',
-                    condition=(invoice_line.origin ==
-                        Concat(PurchaseLine.__name__ + ',', purchase_line.id))
+                    condition=(invoice_line.origin
+                        == Concat(
+                            PurchaseLine.__name__ + ',', purchase_line.id))
                     ).join(move, 'LEFT',
                         condition=(move.origin == Concat(
                                 PurchaseLine.__name__ + ',', purchase_line.id))
@@ -905,7 +906,7 @@
             ondelete='RESTRICT', select=True, required=True)
 
 
-class PurchaseLine(sequence_ordered(), ModelSQL, ModelView):
+class Line(sequence_ordered(), ModelSQL, ModelView):
     'Purchase Line'
     __name__ = 'purchase.line'
     purchase = fields.Many2One('purchase.purchase', 'Purchase',
@@ -1078,7 +1079,7 @@
 
     @classmethod
     def __register__(cls, module_name):
-        super(PurchaseLine, cls).__register__(module_name)
+        super().__register__(module_name)
         table = cls.__table_handler__(module_name)
 
         # Migration from 4.6: drop required on description
@@ -1583,7 +1584,7 @@
                     gettext('purchase.msg_purchase_line_delete_cancel_draft',
                         line=line.rec_name,
                         purchase=line.purchase.rec_name))
-        super(PurchaseLine, cls).delete(lines)
+        super().delete(lines)
 
     @classmethod
     def copy(cls, lines, default=None):
@@ -1595,10 +1596,10 @@
         default.setdefault('moves_ignored', None)
         default.setdefault('moves_recreated', None)
         default.setdefault('invoice_lines', None)
-        return super(PurchaseLine, cls).copy(lines, default=default)
+        return super().copy(lines, default=default)
 
 
-class PurchaseLineTax(ModelSQL):
+class LineTax(ModelSQL):
     'Purchase Line - Tax'
     __name__ = 'purchase.line-account.tax'
     _table = 'purchase_line_account_tax'
@@ -1609,7 +1610,7 @@
             select=True, required=True, domain=[('parent', '=', None)])
 
 
-class PurchaseLineIgnoredMove(ModelSQL):
+class LineIgnoredMove(ModelSQL):
     'Purchase Line - Ignored Move'
     __name__ = 'purchase.line-ignored-stock.move'
     _table = 'purchase_line_moves_ignored_rel'
@@ -1619,7 +1620,7 @@
             select=True, required=True)
 
 
-class PurchaseLineRecreatedMove(ModelSQL):
+class LineRecreatedMove(ModelSQL):
     'Purchase Line - Ignored Move'
     __name__ = 'purchase.line-recreated-stock.move'
     _table = 'purchase_line_moves_recreated_rel'
diff -r 679a8434cbc8 -r 1021f2b72c71 setup.py
--- a/setup.py  Sun Feb 23 13:56:58 2020 +0100
+++ b/setup.py  Sun Mar 01 12:33:53 2020 +0100
@@ -79,8 +79,8 @@
     keywords='tryton purchase',
     package_dir={'trytond.modules.purchase': '.'},
     packages=(
-        ['trytond.modules.purchase'] +
-        ['trytond.modules.purchase.%s' % p for p in find_packages()]
+        ['trytond.modules.purchase']
+        + ['trytond.modules.purchase.%s' % p for p in find_packages()]
         ),
     package_data={
         'trytond.modules.purchase': (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 679a8434cbc8 -r 1021f2b72c71 stock.py
--- a/stock.py  Sun Feb 23 13:56:58 2020 +0100
+++ b/stock.py  Sun Mar 01 12:33:53 2020 +0100
@@ -13,8 +13,6 @@
 from trytond.pool import Pool, PoolMeta
 from trytond.transaction import Transaction
 
-__all__ = ['ShipmentIn', 'ShipmentInReturn', 'Move', 'Location']
-
 
 def process_purchase(moves_field):
     def _process_purchase(func):

Reply via email to