[ty] display variance on hover over type variables#20900
Merged
MichaReiser merged 7 commits intoastral-sh:mainfrom Oct 20, 2025
Merged
[ty] display variance on hover over type variables#20900MichaReiser merged 7 commits intoastral-sh:mainfrom
MichaReiser merged 7 commits intoastral-sh:mainfrom
Conversation
Contributor
Diagnostic diff on typing conformance testsNo changes detected when running ty on typing conformance tests ✅ |
Contributor
|
6e7a976 to
7cd6fa3
Compare
MichaReiser
reviewed
Oct 16, 2025
MichaReiser
approved these changes
Oct 16, 2025
ed8d157 to
16a097c
Compare
Member
|
@mtshiba, unfortunately, there are now some merge conflicts. |
sharkdp
pushed a commit
that referenced
this pull request
Oct 17, 2025
## Summary Derived from #20900 Implement `VarianceInferable` for `KnownInstanceType` (especially for `KnownInstanceType::TypeAliasType`). The variance of a type alias matches its value type. In normal usage, type aliases are expanded to value types, so the variance of a type alias can be obtained without implementing this. However, for example, if we want to display the variance when hovering over a type alias, we need to be able to obtain the variance of the type alias itself (cf. #20900). ## Test Plan I couldn't come up with a way to test this in mdtest, so I'm testing it in a test submodule at the end of `types.rs`. I also added a test to `mdtest/generics/pep695/variance.md`, but it passes without the changes in this PR.
Collaborator
Author
|
Divergence suppression for recursive aliases is addressed in #20969. Please check it out. |
Member
e08b214 to
2dc528c
Compare
This reverts commit 2dc528c.
Collaborator
Author
MichaReiser
approved these changes
Oct 20, 2025
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
Edit: please merge #20924 first
Closes astral-sh/ty#1348
The variance of a type variable is displayed (next to the type) when hovered over.
They are also displayed in the type parameters list.
This is an enhancement to the language server, but also includes some internal additions to
ty_python_semantic(such as calculating variances for type aliases).Test Plan
New tests in
ty_ide/hover/tests.