Skip to content

Commit db1df1f

Browse files
committed
fix(io.ec_data): satisfy ruff (UP037, B905, I001)
- UP037: drop the string-quoted forward reference on EcData.empty's return annotation; the module already uses `from __future__ import annotations`, so the bare class name is fine. - B905: zip(coo.row, coo.col, coo.data) now passes strict=True. The three arrays come from the same COO matrix and are guaranteed equal length; strict=True turns any future drift into a loud TypeError instead of silent truncation. - I001: drop the stray blank line between the import block and the first section comment in tests/test_io_yaml_ec_data.py.
1 parent 39adaf6 commit db1df1f

2 files changed

Lines changed: 5 additions & 3 deletions

File tree

src/raven_python/io/ec_data.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ def validate(self) -> None:
153153

154154
@staticmethod
155155
def empty(n_rxns: int, n_enzymes: int = 0, *,
156-
gecko_light: bool = False) -> "EcData":
156+
gecko_light: bool = False) -> EcData:
157157
"""Preallocate an ``EcData`` with the canonical sentinel values.
158158
159159
Per-rxn fields get empty strings; per-enzyme fields get empty
@@ -311,7 +311,10 @@ def _build_ec_rxns_list(ec: EcData) -> list[dict[str, Any]]:
311311
"""
312312
coo = ec.rxn_enz_mat.tocoo()
313313
per_row_enzymes: list[dict[str, float]] = [{} for _ in range(ec.n_rxns)]
314-
for i, j, v in zip(coo.row, coo.col, coo.data):
314+
# All three arrays come from the same COO matrix, so they're guaranteed
315+
# equal length; strict=True turns any future drift into a loud TypeError
316+
# instead of silent truncation.
317+
for i, j, v in zip(coo.row, coo.col, coo.data, strict=True):
315318
per_row_enzymes[int(i)][ec.enzymes[int(j)]] = float(v)
316319

317320
out: list[dict[str, Any]] = []

tests/test_io_yaml_ec_data.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
from raven_python.io import EcData, read_yaml_model, write_yaml_model
2424
from raven_python.io.yaml import model_from_yaml_data
2525

26-
2726
# --------------------------------------------------------------------------- #
2827
# Helpers
2928
# --------------------------------------------------------------------------- #

0 commit comments

Comments
 (0)