[red-knot] Add callable subtyping for callable instances and bound methods#17105
Merged
carljm merged 8 commits intoastral-sh:mainfrom Apr 1, 2025
Merged
[red-knot] Add callable subtyping for callable instances and bound methods#17105carljm merged 8 commits intoastral-sh:mainfrom
carljm merged 8 commits intoastral-sh:mainfrom
Conversation
Contributor
|
MatthewMckee4
commented
Apr 1, 2025
Comment on lines
4335
to
4341
| let signature = self.function(db).signature(db).clone(); | ||
| let parameters = Parameters::new(signature.parameters().iter().skip(1).cloned()); | ||
|
|
||
| Type::Callable(CallableType::General(GeneralCallableType::new( | ||
| db, | ||
| Signature::new(parameters, signature.return_ty), | ||
| ))) |
Contributor
Author
There was a problem hiding this comment.
I'm not sure this is how we will want to implement this , but i think its right to not check the name of the variable, and since staticmethod is not supported, this should be fine, but when that is implemented i think we will have to check decorators
MichaReiser
reviewed
Apr 1, 2025
Member
|
Not sure, but this might be a good one for @dcreager to review? |
carljm
approved these changes
Apr 1, 2025
Contributor
carljm
left a comment
There was a problem hiding this comment.
This looks reasonable to me! The tests are good, and we can always change the implementation of BoundMethodType::into_callable_type if we decide we need to preserve the first argument.
Thank you!
crates/red_knot_python_semantic/resources/mdtest/type_properties/is_subtype_of.md
Outdated
Show resolved
Hide resolved
crates/red_knot_python_semantic/resources/mdtest/type_properties/is_subtype_of.md
Show resolved
Hide resolved
Co-authored-by: Carl Meyer <[email protected]>
dcreager
approved these changes
Apr 1, 2025
carljm
reviewed
Apr 1, 2025
crates/red_knot_python_semantic/resources/mdtest/type_properties/is_subtype_of.md
Outdated
Show resolved
Hide resolved
crates/red_knot_python_semantic/resources/mdtest/type_properties/is_subtype_of.md
Outdated
Show resolved
Hide resolved
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
Trying to improve #17005
Partially fixes #16953
Test Plan
Update is_subtype_of.md