Skip to content
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

Passing **dict(...) to functools.partial confuses mypy #18644

Open
barisione opened this issue Feb 9, 2025 · 0 comments
Open

Passing **dict(...) to functools.partial confuses mypy #18644

barisione opened this issue Feb 9, 2025 · 0 comments
Labels
bug mypy got something wrong

Comments

@barisione
Copy link

Bug Report

Something like partial(func, **dict(a=1)) confuses mypy which seems to expect the dictionary keys to contain all the arguments to func, leading to errors if positional arguments are not specified (see this playground / gist), or if only a few arguments are specified and later more as passed to partial's return value (see this playground / gist).

Expected Behavior

I realise that mypy cannot know what ends up in an untyped dictionary, but it should maybe just give up in this case.

Actual Behavior

See gist.

Your Environment

  • Mypy version used: mypy 1.15.0 (compiled: yes), but also master while using the playground
  • Mypy command-line flags: none
  • Mypy configuration options from mypy.ini (and other config files): none
  • Python version used: 3.10.1, but also 3.13 while using the playground
@barisione barisione added the bug mypy got something wrong label Feb 9, 2025
@barisione barisione changed the title Passing **dict(...) for functools.partial confused mypy Passing **dict(...) for functools.partial confuses mypy Feb 9, 2025
@barisione barisione changed the title Passing **dict(...) for functools.partial confuses mypy Passing **dict(...) to functools.partial confuses mypy Feb 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug mypy got something wrong
Projects
None yet
Development

No branches or pull requests

1 participant