Skip to content

[1.12 regression] functools.partial and ParamSpec #17960

@daneah

Description

@daneah

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugmypy got something wrong

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions