Further improvements to functools.partial handling#17425
Merged
hauntsaninja merged 7 commits intopython:masterfrom Jul 1, 2024
Merged
Further improvements to functools.partial handling#17425hauntsaninja merged 7 commits intopython:masterfrom
hauntsaninja merged 7 commits intopython:masterfrom
Conversation
- Fixes another crash case / type inference in that case - Fix a false positive when calling the partially applied function - TypeTraverse / comment / daemon test follow up ilevkivskyi mentioned on the original PR
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
ilevkivskyi
approved these changes
Jun 23, 2024
Member
ilevkivskyi
left a comment
There was a problem hiding this comment.
Some nice improvements here, I added more ideas.
| seen_args.add(a) | ||
| actual_args.append(a) | ||
| actual_arg_kinds.append(ctx.arg_kinds[i][j]) | ||
| actual_arg_names.append(ctx.arg_names[i][j]) |
Member
There was a problem hiding this comment.
Looking at this it seems to me a better strategy for the call site may be using get_attribute_hook() for __call__? Unfortunately this hook is not called in is_subtype() etc yet. But at least it will be possible to precisely type-check something like this in future
def foo(fn: Callable[[int, str], int]) -> None: ...
fn = partial(some_other_fn, 1, 2)
foo(fn)
Contributor
|
According to mypy_primer, this change doesn't affect type check results on a corpus of open source code. ✅ |
hauntsaninja
added a commit
that referenced
this pull request
Jul 1, 2024
- Fixes another crash case / type inference in that case - Fix a false positive when calling the partially applied function with kwargs - TypeTraverse / comment / daemon test follow up ilevkivskyi mentioned on the original PR See also #17423
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.
See also #17423