Open
Description
Bug Report
PEP-589 disallows clear and popitem on TypedDicts, even if all known keys are not required, as there may be other required keys due to structural subtyping. However, a @final
-decorated TypedDict cannot be structurally subtyped, so these methods should be available.
To Reproduce
https://mypy-play.net/?mypy=latest&python=3.11&gist=7d42af8206cb1e25a53673bdf4e99df1
from typing import TypedDict, final
@final
class A(TypedDict, total=False):
k: int
a: A = {"k": 1}
a.clear()
Expected Behavior
No errors
Actual Behavior
error: "A" has no attribute "clear" [attr-defined]
Your Environment
- Mypy version used: 1.0.0
- Python version used: 3.11