changeset a50fe223bc45 in modules/company:default
details: https://hg.tryton.org/modules/company?cmd=changeset;node=a50fe223bc45
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 | 6 +++---
party.py | 15 ++++++---------
res.py | 3 ++-
setup.py | 7 ++++---
5 files changed, 17 insertions(+), 16 deletions(-)
diffs (125 lines):
diff -r e1d3298a11d4 -r a50fe223bc45 .flake8
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/.flake8 Sun Mar 01 12:33:52 2020 +0100
@@ -0,0 +1,2 @@
+[flake8]
+ignore=E123,E124,E126,E128,W503
diff -r e1d3298a11d4 -r a50fe223bc45 __init__.py
--- a/__init__.py Wed Feb 12 00:23:04 2020 +0100
+++ b/__init__.py Sun Mar 01 12:33:52 2020 +0100
@@ -25,15 +25,15 @@
ir.Cron,
ir.CronCompany,
party.Configuration,
- party.PartyConfigurationLang,
+ party.ConfigurationLang,
party.Party,
party.PartyLang,
party.ContactMechanism,
module='company', type_='model')
Pool.register(
company.CompanyConfig,
- party.PartyReplace,
- party.PartyErase,
+ party.Replace,
+ party.Erase,
module='company', type_='wizard')
Pool.register(
party.LetterReport,
diff -r e1d3298a11d4 -r a50fe223bc45 party.py
--- a/party.py Wed Feb 12 00:23:04 2020 +0100
+++ b/party.py Sun Mar 01 12:33:52 2020 +0100
@@ -8,15 +8,12 @@
from .company import CompanyReport
from .model import CompanyMultiValueMixin, CompanyValueMixin
-__all__ = ['Configuration', 'PartyConfigurationLang', 'Party', 'PartyLang',
- 'PartyReplace', 'PartyErase', 'ContactMechanism']
-
class Configuration(CompanyMultiValueMixin, metaclass=PoolMeta):
__name__ = 'party.configuration'
-class PartyConfigurationLang(CompanyValueMixin, metaclass=PoolMeta):
+class ConfigurationLang(CompanyValueMixin, metaclass=PoolMeta):
__name__ = 'party.configuration.party_lang'
@classmethod
@@ -26,7 +23,7 @@
table = cls.__table_handler__(module_name)
exist &= table.column_exist('company')
- super(PartyConfigurationLang, cls).__register__(module_name)
+ super().__register__(module_name)
if not exist:
# Re-migrate with company
@@ -62,18 +59,18 @@
field_names, value_names, fields)
-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() + [
('company.company', 'party'),
('company.employee', 'party'),
]
-class PartyErase(metaclass=PoolMeta):
+class Erase(metaclass=PoolMeta):
__name__ = 'party.erase'
def check_erase(self, party):
@@ -81,7 +78,7 @@
Party = pool.get('party.party')
Company = pool.get('company.company')
- super(PartyErase, self).check_erase(party)
+ super().check_erase(party)
with Transaction().set_user(0):
companies = Company.search([])
diff -r e1d3298a11d4 -r a50fe223bc45 res.py
--- a/res.py Wed Feb 12 00:23:04 2020 +0100
+++ b/res.py Sun Mar 01 12:33:52 2020 +0100
@@ -160,7 +160,8 @@
user_id = Transaction().context['user']
result = super(User, cls).read(ids, fields_names=fields_names)
if (fields_names
- and (('company' in fields_names
+ and ((
+ 'company' in fields_names
and 'company' in Transaction().context)
or ('employee' in fields_names
and 'employee' in Transaction().context))):
diff -r e1d3298a11d4 -r a50fe223bc45 setup.py
--- a/setup.py Wed Feb 12 00:23:04 2020 +0100
+++ b/setup.py Sun Mar 01 12:33:52 2020 +0100
@@ -78,8 +78,8 @@
keywords='tryton company employee',
package_dir={'trytond.modules.company': '.'},
packages=(
- ['trytond.modules.company'] +
- ['trytond.modules.company.%s' % p for p in find_packages()]
+ ['trytond.modules.company']
+ + ['trytond.modules.company.%s' % p for p in find_packages()]
),
package_data={
'trytond.modules.company': (info.get('xml', [])
@@ -94,7 +94,8 @@
'Intended Audience :: Financial and Insurance Industry',
'Intended Audience :: Legal Industry',
'Intended Audience :: Manufacturing',
- '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)',