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
This commit is contained in:
Cédric Krier
2020-03-01 12:33:51 +01:00
parent 6b9cf5d51c
commit 822aa3c779
7 changed files with 13 additions and 21 deletions
+2
View File
@@ -0,0 +1,2 @@
[flake8]
ignore=E123,E124,E126,E128,W503
+1 -1
View File
@@ -33,7 +33,7 @@ def register():
account.Journal,
module='account_asset', type_='model')
Pool.register(
purchase.PurchaseLine,
purchase.Line,
module='account_asset', type_='model', depends=['purchase'])
Pool.register(
asset.CreateMoves,
+4 -9
View File
@@ -19,12 +19,6 @@ from trytond.wizard import (Wizard, StateView, StateTransition, StateReport,
from trytond.tools import grouped_slice
from trytond.modules.company import CompanyReport
__all__ = ['Asset', 'AssetLine', 'AssetUpdateMove',
'CreateMovesStart', 'CreateMoves',
'UpdateAssetStart', 'UpdateAssetShowDepreciation', 'UpdateAsset',
'AssetDepreciationTable',
'PrintDepreciationTableStart', 'PrintDepreciationTable']
def date2datetime(date):
return datetime.datetime.combine(date, datetime.time())
@@ -67,7 +61,7 @@ class Asset(Workflow, ModelSQL, ModelView):
supplier_invoice_line = fields.Many2One('account.invoice.line',
'Supplier Invoice Line',
domain=[
If(Eval('product', None) == None,
If(~Eval('product', None),
('product', '=', -1),
('product', '=', Eval('product', -1)),
),
@@ -991,8 +985,9 @@ class AssetDepreciationTable(CompanyReport):
@cached_property
def update_lines(self):
filter_ = lambda l: (l.account.type.expense
and self.start_date < l.move.date <= self.end_date)
def filter_(l):
return (l.account.type.expense
and self.start_date < l.move.date <= self.end_date)
return list(filter(filter_,
(l for m in self.asset.update_moves for l in m.lines)))
-2
View File
@@ -5,8 +5,6 @@ from trytond.pyson import Eval
from trytond.pool import Pool, PoolMeta
from trytond.transaction import Transaction
__all__ = ['InvoiceLine']
class InvoiceLine(metaclass=PoolMeta):
__name__ = 'account.invoice.line'
-2
View File
@@ -7,8 +7,6 @@ from trytond.pool import PoolMeta, Pool
from trytond.modules.account_product.product import (
account_used, template_property)
__all__ = ['Category', 'CategoryAccount', 'Template', 'Product']
class Category(metaclass=PoolMeta):
__name__ = 'product.category'
+2 -4
View File
@@ -5,14 +5,12 @@ from trytond.pool import PoolMeta
from trytond.modules.account_product.exceptions import AccountError
__all__ = ['PurchaseLine']
class PurchaseLine(metaclass=PoolMeta):
class Line(metaclass=PoolMeta):
__name__ = 'purchase.line'
def get_invoice_line(self):
invoice_lines = super(PurchaseLine, self).get_invoice_line()
invoice_lines = super().get_invoice_line()
if (self.product
and self.product.type == 'assets'
and self.product.depreciable):
+4 -3
View File
@@ -81,8 +81,8 @@ setup(name=name,
keywords='tryton account asset',
package_dir={'trytond.modules.account_asset': '.'},
packages=(
['trytond.modules.account_asset'] +
['trytond.modules.account_asset.%s' % p for p in find_packages()]
['trytond.modules.account_asset']
+ ['trytond.modules.account_asset.%s' % p for p in find_packages()]
),
package_data={
'trytond.modules.account_asset': (info.get('xml', [])
@@ -96,7 +96,8 @@ setup(name=name,
'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)',