KEMBAR78
Further improvements to functools.partial handling by hauntsaninja · Pull Request #17425 · python/mypy · GitHub
Skip to content

Conversation

@hauntsaninja
Copy link
Collaborator

@hauntsaninja hauntsaninja commented Jun 22, 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

- 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
@hauntsaninja hauntsaninja requested a review from ilevkivskyi June 22, 2024 22:26
@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

Copy link
Member

@ilevkivskyi ilevkivskyi left a 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])
Copy link
Member

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)

@github-actions
Copy link
Contributor

github-actions bot commented Jul 1, 2024

According to mypy_primer, this change doesn't affect type check results on a corpus of open source code. ✅

@hauntsaninja hauntsaninja merged commit d1d3c78 into python:master Jul 1, 2024
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
@hauntsaninja hauntsaninja deleted the functool-partial-more branch July 2, 2024 00:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants