Closed
Description
Bug Report
Concatenate
causes a false positive in the following example:
To Reproduce
Playground Link
from typing import Protocol
from typing_extensions import ParamSpec, Concatenate
P = ParamSpec("P")
class A(Protocol[P]):
def foo(self, a: int, *args: P.args, **kwargs: P.kwargs):
...
class B(Protocol[P]):
def foo(self, a: int, b: int, *args: P.args, **kwargs: P.kwargs):
...
def bar(b: B[P]) -> A[Concatenate[int, P]]:
return b # error
Expected Behavior
No type error expected, which works with pyright
(pyright playground)
Actual Behavior
# main.py:15: error: Incompatible return value type (got "B[P]", expected "A[[int, **P]]") [return-value]
# main.py:15: note: Following member(s) of "B[P]" have conflicts:
# main.py:15: note: Expected:
# main.py:15: note: def foo(self, a: int, *args: [int, **P.args], **kwargs: [int, **P.kwargs]) -> Any
# main.py:15: note: Got:
# main.py:15: note: def foo(self, a: int, b: int, *args: P.args, **kwargs: P.kwargs) -> Any
# Found 1 error in 1 file (checked 1 source file)
Your Environment
- Mypy version used: 0.991