Skip to content

Incorrect reportArgumentType on partial positional-only arguments #10954

@twoodwark

Description

@twoodwark

Type checking on partial gives incorrect errors for some function signatures.

from collections.abc import Callable
from functools import partial
from typing import Concatenate, reveal_type

# --- This is fine
def unwrapped(s: int, a: int, b: str) -> int: ...

reveal_type(unwrapped)  # Type of "unwrapped" is "(s: int, a: int, b: str) -> int"
partial(unwrapped, 1, 0, "")  # (no error)

# --- This is also fine
def wrapper[T, **P]() -> Callable[[Callable[P, T]], Callable[P, T]]: ...

@wrapper()
def wrapped(s: int, a: int, b: str) -> int: ...

reveal_type(wrapped)  # Type of "wrapped" is "(s: int, a: int, b: str) -> int"
partial(wrapped, 1, 0, "")  # (no error)

# --- This is incorrect, where / appears in the signature
def unwrapped_slash(s: int, /, a: int, b: str) -> int: ...

reveal_type(unwrapped_slash)  # Type of "unwrapped_slash" is "(s: int, /, a: int, b: str) -> int"
partial(unwrapped_slash, 1, 0, "")  # Argument of type "Literal['']" cannot be assigned to parameter "b" of type "int" in function "unwrapped_slash"
partial(unwrapped_slash, 1, "")  # (no error)


# --- This is also incorrect, where Concatenate creates a similar positional-only signature
def wrapper2[T, **P, S]() -> Callable[
    [Callable[Concatenate[S, P], T]], Callable[Concatenate[S, P], T]
]: ...  # ... wrapper2 does something with first argument

@wrapper2()
def wrapped_concat(s: int, a: int, b: str) -> int: ...

reveal_type(wrapped_concat)  # Type of "wrapped_concat" is "(int, a: int, b: str) -> int"

partial(wrapped_concat, 1, 0, "")  # Argument of type "Literal['']" cannot be assigned to parameter "b" of type "int" in function ""

observed in vs code pylance 2025.8.2, and pyright v1.1.405, Python 3.13.2

Metadata

Metadata

Assignees

No one assigned

    Labels

    addressed in next versionIssue is fixed and will appear in next published versionbugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions