Skip to content

(🐞) Bad error message when using Concatenate incorrectly #13518

@KotlinIsland

Description

@KotlinIsland

Despite the fact that a good message is output afterwards, the initial error seems like nonsense: "first arg to Callable must be a parameter specification". Huh? it is a ParamSpec?! I presume that this is because the type becomes Any (from error) due to the args being invalid. At runtime the type here would be Never (because it would raise).

from typing import Concatenate, Callable, ParamSpec, TypeVar, Any

P = ParamSpec("P")

def f(fn: Callable[Concatenate[P, int], None]): ...
main.py:5: error: The first argument to Callable must be a list of types, parameter specification, or "..."
main.py:5: note: See https://mypy.readthedocs.io/en/stable/kinds_of_types.html#callable-types-and-lambdas
main.py:5: error: The last parameter to Concatenate needs to be a ParamSpec
Found 2 errors in 1 file (checked 1 source file)

playground

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions