Bug Report
When a class is generic over a PEP-646/TypeVarTuple/varadic generic and uses that outer generic in a self annotated function, the result of calling that function is incorrect.
To Reproduce
https://mypy-play.net/?gist=e1eb19d739dd5cdc55e99e1ead4fc55c
from typing import reveal_type
class A[*TS]:
def __init__(self, *state: *TS):
self.state: tuple[*TS] = state
def add(self: A[*TS, int, int]) -> A[*TS, int]:
return A(*self.state[:-2], self.state[-2] + self.state[-1])
# Expected type: "A[1, int]" or "A[1, 5]" or similar
# Actual: Revealed type is "__main__.A[Literal[1]?, Literal[2]?, Literal[3]?, int]"
reveal_type(A(1, 2, 3).add())
Expected Behavior
Mypy should either give the correct type for A(1, 2, 3).add(), or give an error somewhere.
Actual Behavior
Mypy silently gives the wrong type for A(1, 2, 3).add()
Your Environment
- Mypy version used: Playground 2.3.1
Bug Report
When a class is generic over a PEP-646/TypeVarTuple/varadic generic and uses that outer generic in a self annotated function, the result of calling that function is incorrect.
To Reproduce
https://mypy-play.net/?gist=e1eb19d739dd5cdc55e99e1ead4fc55c
Expected Behavior
Mypy should either give the correct type for
A(1, 2, 3).add(), or give an error somewhere.Actual Behavior
Mypy silently gives the wrong type for
A(1, 2, 3).add()Your Environment