[red-knot] Improve Symbol API for callable types#14137
Merged
Conversation
sharkdp
commented
Nov 6, 2024
Contributor
|
MichaReiser
reviewed
Nov 6, 2024
carljm
approved these changes
Nov 6, 2024
bf0e9e2 to
54db8aa
Compare
54db8aa to
923d8b3
Compare
carljm
approved these changes
Nov 7, 2024
Contributor
carljm
left a comment
There was a problem hiding this comment.
This looks good to me, just a couple minor nits! Thanks for pushing through a few different versions of this :)
carljm
reviewed
Nov 7, 2024
Comment on lines
1309
to
1311
| let dunder_iter_method = iterable_meta_type.member(db, "__iter__"); | ||
| if let Symbol::Type(dunder_iter_method, _) = dunder_iter_method { | ||
| if let Symbol::Type(dunder_iter_method, boundness) = dunder_iter_method { | ||
| let Some(iterator_ty) = dunder_iter_method.call(db, &[self]).return_ty(db) else { |
Contributor
There was a problem hiding this comment.
Should/can we use call_dunder here?
Contributor
Author
There was a problem hiding this comment.
It's slightly awkward since we only use the boundness information inside the nested conditional, but it's only slightly more code — while being more consistent.
We can actually also use it below for __get_item__ where it improved the code a lot.
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
Symbol::unwrap_or(unclear semantics, not needed anymore)Type::call_dunder__iter__methods__call__methodspart of: #14022
closes #14016
Test Plan
__iter__methods.