Skip to content

fix: remove a stale type: ignore and document value_eq's broad catches - #421

Open
tschm wants to merge 2 commits into
janushendersonassetallocation:masterfrom
tschm:fix/type-ignore-and-value-eq-rationale
Open

fix: remove a stale type: ignore and document value_eq's broad catches#421
tschm wants to merge 2 commits into
janushendersonassetallocation:masterfrom
tschm:fix/type-ignore-and-value-eq-rationale

Conversation

@tschm

@tschm tschm commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

Two quick fixes from the quality assessment in #414, one per commit.

fix(types) — remove a stale suppression (#418)

src/loman/ui/widget.py:352 carried # type: ignore[arg-type] on the **options splat, and ty flagged it as an unused blanket directive — the underlying signature has been tightened since it was added. A stale ignore is worse than none, because it keeps hiding a real arg-type error if one is reintroduced at that call site.

make typecheck reported "Found 1 diagnostic" before this change and "All checks passed!" after.

docs(util) — say why value_eq swallows comparison errors (#420)

Both broad catches in value_eq returned False with no stated reason. The intent is defensible, but it was unwritten — and every other broad catch in the codebase already carries its rationale (computeengine.py:692 logs via LOG.exception; transformer.py:1049 is an optional-extra guard; computation.py:831 has a pragma note; ui/value.py:81 explains that a broken __repr__ must not break the detail panel). These two were the exception.

The rationale comes from the call site rather than from guessing at intent. value_eq has exactly one caller — Computation.insert at computeengine.py:1140 — which uses it only to skip a redundant write on an UPTODATE node. So "not equal" means the value is written and descendents marked STALE: a recomputation that was not needed, rather than a stale graph that looks up to date. That asymmetry is what makes swallowing correct here, and letting the exception escape would instead fail an insert over a comparison the caller never asked to be able to fail.

No behaviour change in either commit — one deleted comment and two added ones.

Verification

Gate Result
make fmt PASS — 21/21 hooks
make typecheck PASS — 0 diagnostics (was 1)
make test PASS — 1542 passed, coverage 98.94%, unchanged

Closes #418
Closes #420

tschm and others added 2 commits September 5, 2026 07:16
The `# type: ignore[arg-type]` on the `**options` splat no longer
suppressed anything -- `ty` reported it as an unused blanket directive.
A stale ignore is worse than none, since it would keep hiding a real
`arg-type` error if one were reintroduced at that call site.

`make typecheck` now reports 0 diagnostics where it previously found 1.

Refs janushendersonassetallocation#418

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Both broad catches in `value_eq` returned False with no stated reason,
which is the shape a reader is trained to distrust -- every other broad
catch in the codebase already carries its rationale.

The asymmetry is what makes swallowing correct here. `value_eq` has one
caller, `Computation.insert`, which uses it only to skip a redundant
write on an UPTODATE node, so "not equal" means the value is written and
descendents marked STALE: a recomputation that was not needed, rather
than a stale graph that looks up to date. Letting the exception escape
would instead fail an insert over a comparison the caller never asked to
be able to fail.

Refs janushendersonassetallocation#420

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Give the two bare catches in value_eq the rationale the others have Remove the stale type: ignore[arg-type] in ui/widget.py

1 participant