Skip to content

Upgrade ty to 0.0.61#81

Merged
davegaeddert merged 3 commits into
masterfrom
claude/zen-allen-tw8788
Jul 20, 2026
Merged

Upgrade ty to 0.0.61#81
davegaeddert merged 3 commits into
masterfrom
claude/zen-allen-tw8788

Conversation

@davegaeddert

@davegaeddert davegaeddert commented Jul 20, 2026

Copy link
Copy Markdown
Member

Summary

  • Bump ty 0.0.59 → 0.0.61 (floor pin in root pyproject.toml, lockfile updated). Checked the changelog for 0.0.60/0.0.61: better isinstance/narrowing accuracy, walrus/tagged-union narrowing, TypeVarTuple/Unpack support, type[Protocol] support, and stricter inference generally.
  • The stricter checker surfaced two real, previously-unnoticed typing bugs, both fixed at the root cause rather than suppressed:
    • AdminViewRegistry.get_nav_sections() (plain-admin/plain/admin/views/registry.py) built a dict[str, list[type]] (bare type), so v.get_nav_title() on the sorted list couldn't resolve. Tightened to dict[str, list[type[AdminView]]], matching the sibling slug_to_view/path_to_view properties in the same class.
    • SQLCompiler._get_field_choices() (plain-postgres/plain/postgres/sql/compiler.py) built its BFS queue from a literal [(None, self.klass_info)], so ty inferred the first tuple slot as literal None instead of list[str] | None, and later queue.extend((path, ...)) calls didn't type-check. Restructured the function to yield "self" up front and seed the queue only from the root's actual children — this also let a None-sentinel and an assert klass_info is not None be removed entirely, since the root/child states are no longer conflated into one Optional-laden tuple shape.
  • Checked for now-unused # ty: ignore suppressions across the repo (ty's own unused-ignore-comment diagnostic) — none found; all 157 remaining suppressions are still needed under 0.0.61.

Test plan

  • ./scripts/type-validate — 27/27 packages pass, 0 diagnostics
  • ./scripts/test plain-admin and ./scripts/test plain-postgres — all tests pass
  • Live smoke test of the refactored _get_field_choices via select_for_update(of=("bogus",)) against a real model with FKs — confirmed the FieldError message (Choices are: self, owner, project.) is unchanged from before the refactor
  • /simplify (4 angles) and /code-review (8 angles, high effort) run against the diff — zero findings survived verification

🤖 Generated with Claude Code

https://claude.ai/code/session_01NJ3p9G233RXYpNfuXLQX2b


Generated by Claude Code

claude added 2 commits July 20, 2026 14:17
ty 0.0.61 (released 2026-07-17) improves isinstance/narrowing accuracy
and lambda parameter inference, which caught two real typing bugs:

- AdminViewRegistry.get_nav_sections() built a dict[str, list[type]]
  (bare `type`), so `v.get_nav_title()` on the sorted list couldn't
  resolve. Tightened to dict[str, list[type[AdminView]]].
- SQLCompiler._get_field_choices()'s BFS queue was inferred too
  narrowly from its literal initializer (first tuple slot pinned to
  `None`), so extending it with `(path, ...)` tuples didn't type-check.
  Added an explicit element-type annotation.

No unused `ty: ignore` suppressions were found under the new version.
The BFS queue conflated two states (root vs. child) via a None
sentinel in the first tuple slot, requiring an `assert klass_info is
not None` to reassure the type checker. Pulling the "yield self" root
step out of the loop and seeding the queue only from actual children
lets the queue's element type drop Optional entirely, and the assert
is no longer needed. Verified the FieldError choices message is
unchanged via a live smoke test.
@pullapprove5

pullapprove5 Bot commented Jul 20, 2026

Copy link
Copy Markdown
PASS: 1 review scope passed
Scope Progress
all 0/0

View in PullApprove

Next steps:

@davegaeddert
davegaeddert enabled auto-merge (squash) July 20, 2026 15:02
@davegaeddert
davegaeddert merged commit 4cd443e into master Jul 20, 2026
9 checks passed
@davegaeddert
davegaeddert deleted the claude/zen-allen-tw8788 branch July 20, 2026 15:05
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.

2 participants