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

[1.12 regression] functools.partial and ParamSpec #17960

Closed
daneah opened this issue Oct 15, 2024 · 2 comments · Fixed by #17355
Closed

[1.12 regression] functools.partial and ParamSpec #17960

daneah opened this issue Oct 15, 2024 · 2 comments · Fixed by #17355
Labels
bug mypy got something wrong

Comments

@daneah
Copy link

daneah commented Oct 15, 2024

Bug Report

A function that takes in a function with a broad signature and returns a narrowed partially-applied function now reports error: Too few arguments [call-arg] in mypy 1.12.

To Reproduce

from functools import partial
from typing import ParamSpec, TypeVar, Callable, Concatenate

P = ParamSpec("P")
R = TypeVar("R")

def partializer(
    func: Callable[Concatenate[int, str, P], R],
    one: int,
    two: str,
) -> Callable[P, R]:
    return partial(func, one, two)

Live playground link

Expected Behavior

mypy has not reported any issue with this incantation historically, and should still not report on (what, as far as my understanding allows, is) valid code.

Actual Behavior

main.py:12: error: Too few arguments  [call-arg]
Found 1 error in 1 file (checked 1 source file)

Your Environment

  • Mypy version used: 1.12
  • Mypy command-line flags: N/A
  • Mypy configuration options from mypy.ini (and other config files): N/A
  • Python version used: 3.9, 3.11, 3.12
@daneah daneah added the bug mypy got something wrong label Oct 15, 2024
sveneberth added a commit to sveneberth/viur-toolkit that referenced this issue Oct 15, 2024
`mypy=1.12.0` has changed a bahavior that is currently not wanted (see
python/mypy#17960).
We should wait for a fix or a "this is the new behavior" statement and
stay so on `1.11.X` for now.
sveneberth added a commit to viur-framework/viur-toolkit that referenced this issue Oct 15, 2024
`mypy=1.12.0` has changed a bahavior that is currently not wanted (see
python/mypy#17960).
We should wait for a fix or a "this is the new behavior" statement and
stay so on `1.11.X` for now.
@hauntsaninja hauntsaninja changed the title 1.12: Regression for functools.partial [1.12 regression] functools.partial and ParamSpec Oct 15, 2024
@hauntsaninja
Copy link
Collaborator

This is probably caused by #17323
See also #17355

@sterliakov
Copy link
Contributor

Yes, the two linked PRs are very relevant: #17355 supports partial application to ParamSpec callables, and without it whole support for ParamSpec+partial is dead. I just resurrected that PR, but I'm not sure if it's the best approach: I would love to hear some feedback. It feels like a right direction, but involves too many partial-specific additions to mypy core.

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

Successfully merging a pull request may close this issue.

3 participants