-
Notifications
You must be signed in to change notification settings - Fork 1.4k
[red-knot] Add callable subtyping for callable instances and bound methods #17105
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
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), | ||
))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
Not sure, but this might be a good one for @dcreager to review? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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]>
Summary
Trying to improve #17005
Partially fixes #16953
Test Plan
Update is_subtype_of.md