-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
Further improvements to functools.partial handling #17425
Further improvements to functools.partial handling #17425
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.
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.
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]) |
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.
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)
According to mypy_primer, this change doesn't affect type check results on a corpus of open source code. ✅ |
- 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
See also #17423