Closed
Description
Mypy gives a false positive on this valid code. The error message seems to indicate that it’s spuriously duplicated the str, bool
parameters to str, bool, str, bool
somewhere.
from typing import Callable, Concatenate, ParamSpec
P = ParamSpec("P")
Q = ParamSpec("Q")
def foo(f: Callable[P, int]) -> Callable[P, int]:
return f
def bar(f: Callable[Concatenate[str, bool, Q], int]) -> Callable[Concatenate[str, bool, Q], int]:
return foo(f)
main.py:10: error: Incompatible return value type (got "Callable[[str, bool, str, bool, **Q], int]", expected "Callable[[str, bool, **Q], int]")
main.py:10: error: Argument 1 to "foo" has incompatible type "Callable[[str, bool, **Q], int]"; expected "Callable[[str, bool, str, bool, **Q], int]"
Found 2 errors in 1 file (checked 1 source file)