-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
[red-knot] Use try_call_dunder
infrastructure consistently
#16371
Comments
The same is probably true for ruff/crates/red_knot_python_semantic/src/types/infer.rs Lines 5220 to 5221 in 1be0dc6
|
And augmented assignments: ruff/crates/red_knot_python_semantic/src/types/infer.rs Lines 2259 to 2267 in 1be0dc6
|
And ruff/crates/red_knot_python_semantic/src/types/infer.rs Lines 4902 to 4910 in 1be0dc6
|
… and subscript expressions (this is the last one, I promise): ruff/crates/red_knot_python_semantic/src/types/infer.rs Lines 5220 to 5238 in 1be0dc6
|
try_call_dunder
infrastructuretry_call_dunder
infrastructure consistently
Summary
__enter__
and__exit__
should be treated like all other dunder methods. However, while working on #16368, I noticed that we look them up manually (and potentially incorrectly) here …ruff/crates/red_knot_python_semantic/src/types/infer.rs
Lines 1621 to 1622 in 1be0dc6
… and call them manually (and potentially incorrectly) here:
ruff/crates/red_knot_python_semantic/src/types/infer.rs
Lines 1660 to 1661 in 1be0dc6
This only leads to incorrect behavior in very exotic situations like the following, where we incorrectly raise a "Object of type
Manager
cannot be used withwith
because it does not correctly implement__enter__
" diagnostic:Fixing this would involve using
try_call_dunder
after #16368 is merged, or usingstatic_member
+ a manual descriptor call, if that is not possible.The text was updated successfully, but these errors were encountered: