-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Closed as not planned
Labels
Description
Bug Report
There seems to be a bug with TypedDict bound TypeVar used in a generic class.
To Reproduce
from typing import Generic, TypeVar, TypedDict
class A(TypedDict):
a: str
T = TypeVar("T", bound=A)
class G(Generic[T]):
a: str
def foo(self, t: T) -> None:
t["a"] = "asd"
self.a = t["a"]
def bar(self) -> T:
return {"a": self.a}Actual Behavior
In foo the first line is correct, but the second throws an error:
test.py:16: error: Incompatible types in assignment (expression has type "object", variable has type "str")
Bar throws an error too:
test.py:19: error: Incompatible return value type (got "Dict[str, str]", expected "T")
Am I missing something or is this a bug?
Your Environment
- Mypy version used: 0.920
- Mypy command-line flags: none
- Python version used: 3.9.7