Summary
from typing_extensions import TypedDict
class Foo(TypedDict):
name: str
def _(td: Foo, key: str) -> None:
# error: [invalid-key]
reveal_type(td["anything"]) # revealed: str
The error here is correct but the revealed type is wrong -- it should either be Unknown or object. This only seems to occur with TypedDicts that have exactly one key. Inferring str might be correct for closed=True or extra_items TypedDicts, but it definitely isn't for open TypedDicts.
Version
No response