Skip to content

Commit c1f7557

Browse files
tbitcsoz-agent
andcommitted
fix: trace.py mypy attr-defined on object — use typed helper _parse_ids()
Replace list comprehension over dict.get() (returns object) with a _parse_ids(raw) helper that uses isinstance(raw, list) guard. Mypy can now verify the comprehension type correctly. Co-Authored-By: Oz <oz-agent@warp.dev>
1 parent c89f57e commit c1f7557

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

src/specsmith/trace.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -110,10 +110,14 @@ def from_dict(cls, d: dict[str, object]) -> SealRecord:
110110
entry_hash=str(d["entry_hash"]),
111111
timestamp=str(d["timestamp"]),
112112
author=str(d.get("author", "specsmith")),
113-
artifact_ids=[
114-
str(x) for x in (d.get("artifact_ids") or []) if isinstance(x, (str, int, float))
115-
],
116-
)
113+
artifact_ids=_parse_ids(d.get("artifact_ids")),
114+
115+
116+
def _parse_ids(raw: object) -> list[str]:
117+
"""Parse artifact_ids from a JSON value safely."""
118+
if not isinstance(raw, list):
119+
return []
120+
return [str(item) for item in raw]
117121

118122

119123
_GENESIS_HASH = "0" * 64

0 commit comments

Comments
 (0)