[ty] Treat ClassVar-qualified Callables as bound-method descriptors#20861
Closed
[ty] Treat ClassVar-qualified Callables as bound-method descriptors#20861
ClassVar-qualified Callables as bound-method descriptors#20861Conversation
ClassVar-qualified Callables as bound-method descriptors
Contributor
Diagnostic diff on typing conformance testsNo changes detected when running ty on typing conformance tests ✅ |
Contributor
|
Contributor
|
| Lint rule | Added | Removed | Changed |
|---|---|---|---|
missing-argument |
0 | 2 | 0 |
unresolved-attribute |
0 | 2 | 0 |
| Total | 0 | 4 | 0 |
Contributor
Author
|
The ecosystem impact is the same as on #20860 (and this PR includes the same changes). So the impact of also treating |
sharkdp
added a commit
that referenced
this pull request
Oct 14, 2025
) ## Summary Dunder methods (at least the ones defined in the standard library) always take an instance of the class as the first parameter. So it seems reasonable to generally treat them as bound method descriptors if they are defined via a `Callable` type. This removes just a few false positives from the ecosystem, but solves three user-reported issues: closes astral-sh/ty#908 closes astral-sh/ty#1143 closes astral-sh/ty#1209 In addition to the change here, I also considered [making `ClassVar`s bound method descriptors](#20861). However, there was zero ecosystem impact. So I think we can also close astral-sh/ty#491 with this PR. closes astral-sh/ty#491 ## Test Plan Added regression test
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
Test Plan