Skip to content

Commit

Permalink
Ruff manual fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
sbidoul committed Oct 28, 2023
1 parent 50d21df commit cc8f77c
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 12 deletions.
2 changes: 1 addition & 1 deletion mis_builder/models/aep.py
Original file line number Diff line number Diff line change
Expand Up @@ -543,4 +543,4 @@ def get_unallocated_pl(cls, companies, date):
# TODO shoud we include here the accounts of type "unaffected"
# or leave that to the caller?
bals = cls._get_balances(cls.MODE_UNALLOCATED, companies, date, date)
return tuple(map(sum, zip(*bals.values())))
return tuple(map(sum, zip(*bals.values(), strict=True)))
2 changes: 1 addition & 1 deletion mis_builder/models/expression_evaluator.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def eval_expressions_by_account(self, expressions, locals_dict):
vals = []
drilldown_args = []
name_error = False
for expr, replaced_expr in zip(exprs, replaced_exprs):
for expr, replaced_expr in zip(exprs, replaced_exprs, strict=True):
val = mis_safe_eval(replaced_expr, locals_dict)
vals.append(val)
if replaced_expr != expr:
Expand Down
15 changes: 9 additions & 6 deletions mis_builder/models/kpimatrix.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,9 @@ def set_values_detail_account(
cell_tuple = []
assert len(vals) == col.colspan
assert len(drilldown_args) == col.colspan
for val, drilldown_arg, subcol in zip(vals, drilldown_args, col.iter_subcols()):
for val, drilldown_arg, subcol in zip(
vals, drilldown_args, col.iter_subcols(), strict=True
):
if isinstance(val, DataError):
val_rendered = val.name
val_comment = val.msg
Expand Down Expand Up @@ -346,7 +348,10 @@ def compute_comparisons(self):
]
comparison_cell_tuple = []
for val, base_val, comparison_subcol in zip(
vals, base_vals, comparison_col.iter_subcols()
vals,
base_vals,
comparison_col.iter_subcols(),
strict=True,
):
# TODO FIXME average factors
comparison = self._style_model.compare_and_render(
Expand Down Expand Up @@ -442,8 +447,7 @@ def iter_rows(self):
yield kpi_row
detail_rows = self._detail_rows[kpi_row.kpi].values()
detail_rows = sorted(detail_rows, key=lambda r: r.label)
for detail_row in detail_rows:
yield detail_row
yield from detail_rows

def iter_cols(self):
"""Iterate columns in display order.
Expand All @@ -460,8 +464,7 @@ def iter_subcols(self):
and comparison.
"""
for col in self.iter_cols():
for subcol in col.iter_subcols():
yield subcol
yield from col.iter_subcols()

def _load_account_names(self):
account_ids = set()
Expand Down
2 changes: 1 addition & 1 deletion mis_builder/models/mis_report_style.py
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,6 @@ def to_css_style(self, props, no_indent=False):
if props.indent_level is not None and not no_indent:
css_attributes.append(("text-indent", f"{props.indent_level}em"))
return (
"; ".join(["%s: %s" % a for a in css_attributes if a[1] is not None])
"; ".join(["{}: {}".format(*a) for a in css_attributes if a[1] is not None])
or None
)
2 changes: 1 addition & 1 deletion mis_builder/models/prorata_read_group_mixin.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def read_group(
date_to = None
assert isinstance(domain, list)
for domain_item in domain:
if isinstance(domain_item, (list, tuple)):
if isinstance(domain_item, list | tuple):
field, op, value = domain_item
if field == "date" and op == ">=":
date_from = value
Expand Down
3 changes: 1 addition & 2 deletions mis_builder/tests/test_mis_report_instance.py
Original file line number Diff line number Diff line change
Expand Up @@ -383,8 +383,7 @@ def test_multi_company_compute(self):
account = self.env["account.account"].browse(row.account_id)
self.assertEqual(
row.label,
"%s %s [%s]"
% (account.code, account.name, account.company_id.name),
f"{account.code} {account.name} [{account.company_id.name}]",
)
self.report_instance.write({"multi_company": False})
matrix = self.report_instance._compute_matrix()
Expand Down

0 comments on commit cc8f77c

Please sign in to comment.