changeset a7fecb98c989 in modules/sale:default
details: https://hg.tryton.org/modules/sale?cmd=changeset;node=a7fecb98c989
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 | 60 +++++++++++++++++++++++++++---------------------------
configuration.py | 2 -
invoice.py | 10 +++-----
party.py | 10 +++-----
sale_reporting.py | 8 -------
setup.py | 7 +++--
stock.py | 2 -
8 files changed, 44 insertions(+), 57 deletions(-)
diffs (242 lines):
diff -r 5224768fce88 -r a7fecb98c989 .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 5224768fce88 -r a7fecb98c989 __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,36 +2,36 @@
# this repository contains the full copyright notices and license terms.
from trytond.pool import Pool
-from .sale import *
+from . import sale
from . import product
-from .stock import *
-from .configuration import *
-from .invoice import *
+from . import stock
+from . import configuration
+from . import invoice
from . import party
from . import sale_reporting
def register():
Pool.register(
- Move,
- Sale,
- SaleIgnoredInvoice,
- SaleRecreatedInvoice,
- SaleLine,
- SaleLineTax,
- SaleLineIgnoredMove,
- SaleLineRecreatedMove,
+ stock.Move,
+ sale.Sale,
+ sale.SaleIgnoredInvoice,
+ sale.SaleRecreatedInvoice,
+ sale.SaleLine,
+ sale.SaleLineTax,
+ sale.SaleLineIgnoredMove,
+ sale.SaleLineRecreatedMove,
product.Template,
product.Product,
product.SaleContext,
- ShipmentOut,
- ShipmentOutReturn,
- HandleShipmentExceptionAsk,
- HandleInvoiceExceptionAsk,
- ReturnSaleStart,
- Configuration,
- ConfigurationSequence,
- ConfigurationSaleMethod,
+ stock.ShipmentOut,
+ stock.ShipmentOutReturn,
+ sale.HandleShipmentExceptionAsk,
+ sale.HandleInvoiceExceptionAsk,
+ sale.ReturnSaleStart,
+ configuration.Configuration,
+ configuration.ConfigurationSequence,
+ configuration.ConfigurationSaleMethod,
sale_reporting.Context,
sale_reporting.Customer,
sale_reporting.CustomerTimeseries,
@@ -45,19 +45,19 @@
sale_reporting.Subdivision,
sale_reporting.SubdivisionTimeseries,
sale_reporting.Region,
- Invoice,
- InvoiceLine,
+ invoice.Invoice,
+ invoice.Line,
module='sale', type_='model')
Pool.register(
- OpenCustomer,
- HandleShipmentException,
- HandleInvoiceException,
- ReturnSale,
- ModifyHeader,
- party.PartyReplace,
- party.PartyErase,
+ sale.OpenCustomer,
+ sale.HandleShipmentException,
+ sale.HandleInvoiceException,
+ sale.ReturnSale,
+ sale.ModifyHeader,
+ party.Replace,
+ party.Erase,
sale_reporting.OpenRegion,
module='sale', type_='wizard')
Pool.register(
- SaleReport,
+ sale.SaleReport,
module='sale', type_='report')
diff -r 5224768fce88 -r a7fecb98c989 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', 'ConfigurationSaleMethod']
sale_invoice_method = fields.Selection(
'get_sale_invoice_methods', "Sale Invoice Method")
sale_shipment_method = fields.Selection(
diff -r 5224768fce88 -r a7fecb98c989 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_sale(func):
@wraps(func)
@@ -102,21 +100,21 @@
return super(Invoice, cls).draft(invoices)
-class InvoiceLine(metaclass=PoolMeta):
+class Line(metaclass=PoolMeta):
__name__ = 'account.invoice.line'
@property
def origin_name(self):
pool = Pool()
SaleLine = pool.get('sale.line')
- name = super(InvoiceLine, self).origin_name
+ name = super().origin_name
if isinstance(self.origin, SaleLine):
name = self.origin.sale.rec_name
return name
@classmethod
def _get_origin(cls):
- models = super(InvoiceLine, cls)._get_origin()
+ models = super()._get_origin()
models.append('sale.line')
return models
@@ -128,6 +126,6 @@
invoices = (l.invoice for l in cls.browse(lines)
if l.type == 'line' and l.invoice)
sales = set(s for i in invoices for s in i.sales)
- super(InvoiceLine, cls).delete(lines)
+ super().delete(lines)
if sales:
Sale.__queue__.process(sales)
diff -r 5224768fce88 -r a7fecb98c989 party.py
--- a/party.py Sun Feb 23 13:56:58 2020 +0100
+++ b/party.py Sun Mar 01 12:33:53 2020 +0100
@@ -5,27 +5,25 @@
from trytond.modules.party.exceptions import EraseError
-__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() + [
('sale.sale', 'party'),
('sale.sale', 'shipment_party'),
]
-class PartyErase(metaclass=PoolMeta):
+class Erase(metaclass=PoolMeta):
__name__ = 'party.erase'
def check_erase_company(self, party, company):
pool = Pool()
Sale = pool.get('sale.sale')
- super(PartyErase, self).check_erase_company(party, company)
+ super().check_erase_company(party, company)
sales = Sale.search([
['OR',
diff -r 5224768fce88 -r a7fecb98c989 sale_reporting.py
--- a/sale_reporting.py Sun Feb 23 13:56:58 2020 +0100
+++ b/sale_reporting.py Sun Mar 01 12:33:53 2020 +0100
@@ -20,14 +20,6 @@
from trytond.wizard import Wizard, StateTransition, StateAction
from trytond.i18n import lazy_gettext
-__all__ = ['Context',
- 'Customer', 'CustomerTimeseries',
- 'Product', 'ProductTimeseries',
- 'Category', 'CategoryTimeseries', 'CategoryTree',
- 'Country', 'CountryTimeseries',
- 'Subdivision', 'SubdivisionTimeseries',
- 'Region', 'OpenRegion']
-
def pairwise(iterable):
a, b = tee(iterable)
diff -r 5224768fce88 -r a7fecb98c989 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 sale',
package_dir={'trytond.modules.sale': '.'},
packages=(
- ['trytond.modules.sale'] +
- ['trytond.modules.sale.%s' % p for p in find_packages()]
+ ['trytond.modules.sale']
+ + ['trytond.modules.sale.%s' % p for p in find_packages()]
),
package_data={
'trytond.modules.sale': (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 5224768fce88 -r a7fecb98c989 stock.py
--- a/stock.py Sun Feb 23 13:56:58 2020 +0100
+++ b/stock.py Sun Mar 01 12:33:53 2020 +0100
@@ -8,8 +8,6 @@
from trytond.transaction import Transaction
from trytond.pool import Pool, PoolMeta
-__all__ = ['ShipmentOut', 'ShipmentOutReturn', 'Move']
-
def process_sale(moves_field):
def _process_sale(func):