Upgrade ty to 0.0.61#81
Merged
Merged
Conversation
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.
|
Next steps:
|
davegaeddert
enabled auto-merge (squash)
July 20, 2026 15:02
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
ty0.0.59 → 0.0.61 (floor pin in rootpyproject.toml, lockfile updated). Checked the changelog for 0.0.60/0.0.61: better isinstance/narrowing accuracy, walrus/tagged-union narrowing,TypeVarTuple/Unpacksupport,type[Protocol]support, and stricter inference generally.AdminViewRegistry.get_nav_sections()(plain-admin/plain/admin/views/registry.py) built adict[str, list[type]](baretype), sov.get_nav_title()on the sorted list couldn't resolve. Tightened todict[str, list[type[AdminView]]], matching the siblingslug_to_view/path_to_viewproperties 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 literalNoneinstead oflist[str] | None, and laterqueue.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 aNone-sentinel and anassert klass_info is not Nonebe removed entirely, since the root/child states are no longer conflated into oneOptional-laden tuple shape.# ty: ignoresuppressions across the repo (ty's ownunused-ignore-commentdiagnostic) — 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-adminand./scripts/test plain-postgres— all tests pass_get_field_choicesviaselect_for_update(of=("bogus",))against a real model with FKs — confirmed theFieldErrormessage (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