Skip to content

Commit

Permalink
Reduce max-complexity 15 → 13
Browse files Browse the repository at this point in the history
- Mark one additional exception.
- Update exceptions.
  • Loading branch information
khaeru committed Mar 28, 2024
1 parent 1e6eda6 commit 32ab4de
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 8 deletions.
2 changes: 1 addition & 1 deletion ixmp/backend/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ def maybe_init_item(scenario, ix_type, name, new_idx, path):
raise ValueError from None


# FIXME reduce complexity from 26 to <=15
# FIXME reduce complexity 22 → ≤13
def s_read_excel( # noqa: C901
be, s, path, add_units=False, init_items=False, commit_steps=False
):
Expand Down
2 changes: 1 addition & 1 deletion ixmp/backend/jdbc.py
Original file line number Diff line number Diff line change
Expand Up @@ -965,7 +965,7 @@ def item_index(self, s, name, sets_or_names):
jitem = self._get_item(s, "item", name, load=False)
return list(getattr(jitem, f"getIdx{sets_or_names.title()}")())

# FIXME reduce complexity from 19 to <=15
# FIXME reduce complexity 18 → ≤13
def item_get_elements(self, s, type, name, filters=None): # noqa: C901
if filters:
# Convert filter elements to strings
Expand Down
5 changes: 3 additions & 2 deletions ixmp/core/scenario.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ def set(
"""
return self._backend("item_get_elements", "set", name, filters)

# FIXME reduce complexity from 17 to <=15
# FIXME reduce complexity 18 → ≤13
def add_set( # noqa: C901
self,
name: str,
Expand Down Expand Up @@ -535,7 +535,8 @@ def list_items(
#: List all defined variables. See :meth:`list_items`.
var_list = partialmethod(list_items, ItemType.VAR)

def add_par(
# FIXME reduce complexity 15 → ≤13
def add_par( # noqa: C901
self,
name: str,
key_or_data: Optional[Union[str, Sequence[str], Dict, pd.DataFrame]] = None,
Expand Down
9 changes: 5 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,11 @@ markers = [
[tool.ruff.lint]
select = ["C9", "E", "F", "I", "W"]
# FIXME the following exceed this limit
# .backend.io.s_read_excel: 26
# .backend.jdbc.JDBCBackend.item_get_elements: 19
# .core.scenario.Scenario.add_set: 17
mccabe.max-complexity = 15
# .backend.io.s_read_excel: 22
# .backend.jdbc.JDBCBackend.item_get_elements: 18
# .core.scenario.Scenario.add_par: 15
# .core.scenario.Scenario.add_set: 18
mccabe.max-complexity = 13

[tool.setuptools.packages]
find = {}
Expand Down

0 comments on commit 32ab4de

Please sign in to comment.