Skip to content

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

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

Activity

  1. KotlinIsland commented on Aug 28, 2022

    @KotlinIsland
    ContributorAuthor

    @sobolevn Should the message The first argument to Callable must be a list of types, parameter specification, or "..." be updated to include Concatenate or do you think that Concatenate falls under "parameter specification"?

  2. sobolevn commented on Aug 28, 2022

    @sobolevn
    Member

    do you think that Concatenate falls under "parameter specification"?

    I think this is correct 🤔

  3. gandhis1 commented on Nov 10, 2022

    @gandhis1

    Does MyPy actually support Concatenate? I attempted to use it, but it's rejecting my first parameter in Callable[Concatenate[Dict[str, sa.Table], P], sa.sql.expression.Selectable]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions