Bug Report?
I may be misunderstanding how TypeVar works, but it seems to me that the following usage with TypeDict should be valid, however I get the error indicated in the comment:
from typing import TypedDict, TypeVar
class Data(TypedDict):
x: int
T = TypeVar("T", bound=Data)
def f(data: T) -> int:
return data["x"] + 1 # E: Unsupported operand types for + ("object" and "int")
assert f(Data(x=1)) == 2
Report Details
- have you tried it on
master: no
- what version of MyPy: 0.761
- what flags are you using: none
Bug Report?
I may be misunderstanding how
TypeVarworks, but it seems to me that the following usage withTypeDictshould be valid, however I get the error indicated in the comment:Report Details
master: no