[ty] Prefer declared type of generic classes#21070
Closed
ibraheemdev wants to merge 1 commit intomainfrom
Closed
Conversation
cf8b71b to
c563650
Compare
Contributor
Diagnostic diff on typing conformance testsNo changes detected when running ty on typing conformance tests ✅ |
c563650 to
fdbb426
Compare
Contributor
|
Contributor
|
| Lint rule | Added | Removed | Changed |
|---|---|---|---|
invalid-assignment |
2 | 1 | 0 |
invalid-argument-type |
0 | 2 | 0 |
index-out-of-bounds |
0 | 1 | 0 |
invalid-return-type |
0 | 0 | 1 |
unused-ignore-comment |
0 | 1 | 0 |
| Total | 2 | 5 | 1 |
Member
Author
|
I'm not sure if we should restrict this change to invariant generics. It seems reasonable to use |
Contributor
|
@ibraheemdev Is this blocked? What's keeping it in draft? |
CodSpeed Performance ReportMerging #21070 will not alter performanceComparing Summary
Footnotes
|
2f4a925 to
0ee0e3f
Compare
This was referenced Oct 31, 2025
ibraheemdev
added a commit
that referenced
this pull request
Oct 31, 2025
ibraheemdev
added a commit
that referenced
this pull request
Oct 31, 2025
…1165) ## Summary The solver is currently order-dependent, and will choose a supertype over the exact type if it appears earlier in the list of constraints. We could be smarter and try to choose the most precise subtype, but I imagine this is something the new constraint solver will fix anyways, and this fixes the issue showing up on #21070.
0ee0e3f to
2f4dcbf
Compare
Member
Author
|
The ecosystem changes all seem correct. |
Member
Author
|
Superceded by #21210. |
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
Extends #20927 to generic call inference, preferring the declared type of generic classes:
Part of astral-sh/ty#136.