[ty] Fix panic on list[Annotated[()]]#24303
Merged
AlexWaygood merged 1 commit intomainfrom Mar 30, 2026
Merged
Conversation
Typing conformance resultsNo changes detected ✅Current numbersThe percentage of diagnostics emitted that were expected errors held steady at 86.61%. The percentage of expected errors that received a diagnostic held steady at 81.56%. The number of fully passing files held steady at 70/132. |
Memory usage reportSummary
Significant changesClick to expand detailed breakdownsphinx
prefect
|
|
charliermarsh
approved these changes
Mar 30, 2026
| @@ -1,6 +1,5 @@ | |||
| --- | |||
| source: crates/ty_test/src/lib.rs | |||
| assertion_line: 621 | |||
Member
There was a problem hiding this comment.
(Not sure if intentional?)
Member
Author
There was a problem hiding this comment.
it was intentional... Somebody (or somebody's agent) has an old version of cargo-insta installed locally, which means that snapshots in "legacy formats" keep getting added, which then results in a bunch of annoying, noisy warnings being printed locally whenever you run cargo test -p ty_python_semantic --test=mdtest (or run uv run crates/ty_python_semantic/mdtest.py). The only way to fix the warnings is by running --force-update-snapshots locally, and this is the result. I could split it into its own PR, but that causes its own kind of churn...
carljm
added a commit
that referenced
this pull request
Mar 31, 2026
* main: (35 commits) Store definition indexes as u32 (#24307) Avoid re-using symbol in RUF024 fix (#24316) [ty] Add materialization to `Divergent` type (#24255) [ty] Make `Divergent` a top-level type variant (#24252) [ty] Fix nested global and nonlocal lookups through forwarding scopes (#24279) Fetch the cargo-dist binary directly instead of using the installer (#24258) [ty] Fix panic on `list[Annotated[()]]` (#24303) Don't measure the AST deallocation time in parser benchmarks (#24301) Enable CodSpeed's memory benchmarks for simulation benchmarks (#24298) Upgrade imara-diff to 0.2.0 (#24299) [ty] Represent `InitVar` as a special form internally, not a class (#24248) `RUF067`: Allow dunder-named assignments in non-strict mode [`pyupgrade`] UP018 should detect more unnecessarily wrapped literals (UP018) (#24093) [ty] Remove unused `system.glob` method (#24300) [ty] Reject functional TypedDict with mismatched name (#24295) Update Rust crate arc-swap to v1.9.0 (#24292) [ty] Remove unused `@Todo(Functional TypedDicts)` (#24297) Update CodSpeedHQ/action action to v4.12.1 (#24290) Update taiki-e/install-action action to v2.69.6 (#24293) Update Rust crate toml to v1.0.7 (#24289) ...
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.
Fixes astral-sh/ty#3179
Annotatedis special because it can appear in annotation expressions, type expressions and type aliases. It should be parsed nearly the same way in all contexts, but with the subtle distinction that if it appears inside a type expression or type alias, it is only allowed to have type expressions inside it, whereas it is allowed to have annotation expressions inside it if it appears inside an annotation expression.This difference has led to us implementing
Annotatedtype-expression parsing twice, and that resulted in us gracefully recovering fromx: Annotated[()]but panicking onx: list[Annotated[()]](in the first example,Annotatedappears in an annotation expression; in the second, it appears in a type expression).This PR fixes the bug by unifying the logic into a single place where
Annotatedsubscriptions are inferred.