changeset b27553f9b64c in modules/project_plan:default
details:
https://hg.tryton.org/modules/project_plan?cmd=changeset;node=b27553f9b64c
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 | 12 ++++++------
allocation.py | 2 --
setup.py | 7 ++++---
work.py | 42 +++++++++++++++++++++++++++---------------
5 files changed, 39 insertions(+), 26 deletions(-)
diffs (144 lines):
diff -r 9d243b819255 -r b27553f9b64c .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 9d243b819255 -r b27553f9b64c __init__.py
--- a/__init__.py Wed Dec 04 11:09:36 2019 +0100
+++ b/__init__.py Sun Mar 01 12:33:53 2020 +0100
@@ -2,16 +2,16 @@
# this repository contains the full copyright notices and license terms.
from trytond.pool import Pool
-from .allocation import *
-from .work import *
+from . import allocation
+from . import work
def register():
Pool.register(
- Allocation,
- Work,
- PredecessorSuccessor,
+ allocation.Allocation,
+ work.Work,
+ work.PredecessorSuccessor,
module='project_plan', type_='model')
Pool.register(
- Leveling,
+ work.Leveling,
module='project_plan', type_='wizard')
diff -r 9d243b819255 -r b27553f9b64c allocation.py
--- a/allocation.py Wed Dec 04 11:09:36 2019 +0100
+++ b/allocation.py Sun Mar 01 12:33:53 2020 +0100
@@ -3,8 +3,6 @@
from trytond.model import ModelView, ModelSQL, fields
from trytond.pool import Pool
-__all__ = ['Allocation']
-
class Allocation(ModelSQL, ModelView):
'Allocation'
diff -r 9d243b819255 -r b27553f9b64c setup.py
--- a/setup.py Wed Dec 04 11:09:36 2019 +0100
+++ b/setup.py Sun Mar 01 12:33:53 2020 +0100
@@ -78,8 +78,8 @@
keywords='tryton project planning',
package_dir={'trytond.modules.project_plan': '.'},
packages=(
- ['trytond.modules.project_plan'] +
- ['trytond.modules.project_plan.%s' % p for p in find_packages()]
+ ['trytond.modules.project_plan']
+ + ['trytond.modules.project_plan.%s' % p for p in find_packages()]
),
package_data={
'trytond.modules.project_plan': (info.get('xml', [])
@@ -93,7 +93,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)',
diff -r 9d243b819255 -r b27553f9b64c work.py
--- a/work.py Wed Dec 04 11:09:36 2019 +0100
+++ b/work.py Sun Mar 01 12:33:53 2020 +0100
@@ -11,8 +11,6 @@
from trytond.transaction import Transaction
from trytond.pool import Pool, PoolMeta
-__all__ = ['Work', 'PredecessorSuccessor', 'Leveling']
-
def intfloor(x):
return int(round(x, 4))
@@ -258,12 +256,20 @@
def compute_dates(self):
values = {}
- get_early_finish = lambda work: values.get(work, {}).get(
- 'early_finish_time', work.early_finish_time)
- get_late_start = lambda work: values.get(work, {}).get(
- 'late_start_time', work.late_start_time)
- maxdate = lambda x, y: x and y and max(x, y) or x or y
- mindate = lambda x, y: x and y and min(x, y) or x or y
+
+ def get_early_finish(work):
+ return values.get(work, {}).get(
+ 'early_finish_time', work.early_finish_time)
+
+ def get_late_start(work):
+ return values.get(work, {}).get(
+ 'late_start_time', work.late_start_time)
+
+ def maxdate(x, y):
+ return x and y and max(x, y) or x or y
+
+ def mindate(x, y):
+ return x and y and min(x, y) or x or y
# propagate constraint_start_time
constraint_start = reduce(maxdate, (pred.early_finish_time
@@ -443,8 +449,10 @@
self.write(*to_write)
def reset_leveling(self):
- get_key = lambda w: (set(p.id for p in w.predecessors),
- set(s.id for s in w.successors))
+ def get_key(w):
+ return (
+ set(p.id for p in w.predecessors),
+ set(s.id for s in w.successors))
if not self.parent:
return
@@ -468,14 +476,18 @@
def create_leveling(self):
# define some helper functions
- get_key = lambda w: (set(p.id for p in w.predecessors),
- set(s.id for s in w.successors))
- over_alloc = lambda current_alloc, work: (
- reduce(lambda res, alloc: (res
+ def get_key(w):
+ return (
+ set(p.id for p in w.predecessors),
+ set(s.id for s in w.successors))
+
+ def over_alloc(current_alloc, work):
+ return reduce(lambda res, alloc: (
+ res
or (current_alloc[alloc.employee.id]
+ alloc.percentage) > 100),
work.allocations,
- False))
+ False)
def sum_allocs(current_alloc, work):
res = defaultdict(float)