Bug Report
The code below passed with mypy 1.1.1 but not in 1.2.0
To Reproduce
from typing import Concatenate, Callable, ParamSpec, Protocol
P = ParamSpec("P")
class Decorator(Protocol):
def __call__(self, fct: Callable[Concatenate[str, P], int]) -> Callable[P, int]:
...
def foo(value: int) -> Decorator:
def bar(fct: Callable[Concatenate[str, P], int]) -> Callable[P, int]:
raise NotImplementedError
return bar
I haven't been able to strip down any further, it seems that it has something to do with both Callable and Concatenate.
Expected Behavior
No error (as in mypy 1.1.1).
Actual Behavior
The following error is displayed:
issue.py:15: error: Incompatible return value type (got "Callable[[Callable[[str, **P], int]], Callable[P, int]]", expected "Decorator") [return-value]
issue.py:15: note: "Decorator.__call__" has type "Callable[[Arg(Callable[[str, **P], int], 'fct')], Callable[P, int]]"
Found 1 error in 1 file (checked 1 source file)
Note that I have tried to change the Decorator definition to make fct parameter positional-only:
class Decorator(Protocol):
def __call__(self, fct: Callable[Concatenate[str, P], int], /) -> Callable[P, int]:
...
Which resulted in the error message being even more confusing:
issue.py:15: error: Incompatible return value type (got "Callable[[Callable[[str, **P], int]], Callable[P, int]]", expected "Decorator") [return-value]
issue.py:15: note: "Decorator.__call__" has type "Callable[[Callable[[str, **P], int]], Callable[P, int]]"
Found 1 error in 1 file (checked 1 source file)
Your Environment
- Mypy version used: 1.2.0
- Mypy command-line flags: none
- Mypy configuration options from
mypy.ini (and other config files): none
- Python version used: 3.11.3
Bug Report
The code below passed with mypy
1.1.1but not in1.2.0To Reproduce
I haven't been able to strip down any further, it seems that it has something to do with both
CallableandConcatenate.Expected Behavior
No error (as in mypy 1.1.1).
Actual Behavior
The following error is displayed:
Note that I have tried to change the
Decoratordefinition to makefctparameter positional-only:Which resulted in the error message being even more confusing:
Your Environment
mypy.ini(and other config files): none