Commit 9ecc4857 authored by Christophe Benz's avatar Christophe Benz

Add flake8 with plugins, fix errors

parent 28329e45
......@@ -8,6 +8,12 @@ Inside a virtualenv:
pip install -r requirements.txt
```
While developing, install extra requirements (e.g. formatter, code style checkers...):
```bash
pip install -r requirements-dev.txt
```
## Run
```
......
......@@ -20,7 +20,7 @@ COLORS = [
]
def noneIfEmpty(val):
def none_if_empty(val):
"""Return None if empty else original value."""
return None if val == "" else val
......@@ -74,7 +74,7 @@ app.layout = html.Div(
)
def update_dept_dropdown_options(reg_code):
"""Update department list when a region has been chosen."""
return compute_dept_dropdown_options(reg_code=noneIfEmpty(reg_code))
return compute_dept_dropdown_options(reg_code=none_if_empty(reg_code))
@app.callback(
......@@ -96,7 +96,7 @@ def update_dep_dropdown_value(reg_code):
def update_type_bar(reg_code, dep_code):
"""Update bar chart when one dropdown value changes."""
return compute_bar_figure(
reg_code=noneIfEmpty(reg_code), dep_code=noneIfEmpty(dep_code)
reg_code=none_if_empty(reg_code), dep_code=none_if_empty(dep_code)
)
......
......@@ -36,19 +36,15 @@ reg_dep_set = {
}
COLL_TYPES = sorted(df["type"].unique().tolist())
# (reg_code, reg_nom) list
reg_set = {(t[0], t[1]) for t in reg_dep_set}
reg_list = sorted(reg_set, key=lambda t: unaccentize(t[1]))
# (reg_code, dep_code, dep_nom) list
reg_dep_list = [(t[0], t[2], t[3]) for t in sorted(reg_dep_set, key=itemgetter(2))]
# { reg_code : list of dep_code }
reg_dep_list_map: Dict[str, List[str]] = defaultdict(list)
for t in reg_dep_set:
reg_dep_list_map[t[0]].append(t[2])
# { dep_code: reg_code }
dep_reg_map = {t[1]: t[0] for t in reg_dep_list}
......
black
flake8
flake8-black
flake8-blind-except
flake8-breakpoint
flake8-bugbear
flake8-builtins
flake8-comprehensions
flake8-eradicate
flake8-fixme
flake8-isort
flake8-logging-format
flake8-mutable
flake8-print
flake8-rst-docstrings
isort
mypy
pep8-naming
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment