[ty] Add diagnostic hint on unresolved-reference to suggest using "list" instead of "List"#22827
Merged
oconnor663 merged 5 commits intoastral-sh:mainfrom Jan 28, 2026
Merged
Conversation
Typing conformance resultsNo changes detected ✅ |
|
oconnor663
requested changes
Jan 26, 2026
Contributor
oconnor663
left a comment
There was a problem hiding this comment.
LGTM overall. One comment on the info: hint.
| | ^^^^ Did you mean `list`? | ||
| 2 | bar: Type # error: [unresolved-reference] | ||
| | | ||
| info: Python 3.9 was assumed when resolving types because it was specified on the command line |
Contributor
There was a problem hiding this comment.
I think extra info: like this is more useful when it's explaining behavior that doesn't happen by default / under the most recent Python version. But in this case it's a bit noisy without adding a lot of value?
Contributor
Author
There was a problem hiding this comment.
Understood, removed.
oconnor663
approved these changes
Jan 28, 2026
unresolved-reference.unresolved-reference to suggest using "list" instead of "List"
carljm
added a commit
that referenced
this pull request
Jan 30, 2026
* main: (76 commits) [ty] Improve the check for `NewType`s with generic bases (#22961) [ty] Ban legacy `TypeVar` bounds or constraints from containing type variables (#22949) Bump the typing conformance suite pin (#22960) [ty] Emit an error if a TypeVarTuple is used to subscript `Generic` or `Protocol` without being unpacked (#22952) [ty] Reduce false positives when subscripting classes generic over `TypeVarTuple`s (#22950) [ty] Detect invalid attempts to subclass `Protocol[]` and `Generic[]` simultaneously (#22948) Fix suppression indentation matching (#22903) Remove hidden `--output-format` warning (#22944) [ty] Validate signatures of dataclass `__post_init__` methods (#22730) [ty] extend special-cased `numbers` diagnostic to `invalid-argument-type` errors (#22938) [ty] Avoid false positive for `not-iterable` with no-positive intersection types (#22089) [ty] Preserve pure negation types in descriptor protocol (#22907) [ty] add special-case diagnostic for `numbers` module (#22931) [ty] Move the location of more `invalid-overload` diagnostics (#22933) [ty] Fix unary and comparison operators for TypeVars with union bounds (#22925) [ty] Rule Selection: ignore/warn/select all rules (unless subsequently overriden) (#22832) [ty] Fix TypedDict construction from existing TypedDict values (#22904) [ty] fix bug in string annotations and clean up diagnostics (#22913) [ty] Improve support for goto-type, goto-declaration, hover, and highlighting of string annotations (#22878) [ty] Rename old typing imports to new on `unresolved-reference`. (#22827) ...
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
Closes astral-sh/ty#1665 .
This PR adds an info message to the diagnostic for
unresolved-referencein Python 3.9+ when the reference is one of the capitalized type hints that are in thetypingmodule, such astyping.List, pointing the user to the new lowercase instances instead. Example:Test Plan
Added a pair of new testcases, one which tests that the full info message shows up in the snapshot for Python 3.9, and another with the same code that checks that the info message does not show up in the snapshot for Python 3.8.