You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
typing_extensions.TypedDict state vars have untyped keys because typing.is_typeddict returns False #7996
A state var typed with a typing_extensions.TypedDict has untyped keys. State.a["x"] has _var_typeAny, and an unknown key (State.a["missing"]) gives no error. So operations that need a type fail later with UntypedVarError, for example State.a["name"].join(...). The same class written with typing.TypedDict works.
The cause: vars/object.py and _isinstance in utils/types.py import is_typeddict from typing. On Python 3.11 to 3.14 with typing_extensions 4.16, typing_extensions.TypedDict is a different class from typing.TypedDict, and typing.is_typeddict returns False for it:
Other code in utils/types.py already uses typing_extensions.is_typeddict (get_typed_dict_field_types, _get_column_access_type, and the #7887 branch in get_attribute_access_type). So the same class is a TypedDict in some places and not in others. The _isinstance path (if is_typeddict(cls)) is affected too, so assignments to these vars are not checked against the field types.
Pydantic and other libraries tell users to use typing_extensions.TypedDict on Python < 3.12, so this is ordinary code.
Checked on main at 1e4eb60, Python 3.14.6, typing_extensions 4.16.0.
Expected
The same behavior as typing.TypedDict: State.a["x"] is typed int, and an unknown key raises VarAttributeError.
Fix direction
Import is_typeddict from typing_extensions in vars/object.py and utils/types.py. typing_extensions.is_typeddict also returns True for typing.TypedDict classes. Add a test that runs the existing TypedDict key-access tests with both TypedDict classes.
picking this up, swapping both imports to typing_extensions.is_typeddict and adding tests that run key access and _isinstance with both TypedDict flavors. PR soon
Activity
linear-code commentedon Nov 25, 2026
ENG-14947
cestercian commentedon Nov 26, 2026
picking this up, swapping both imports to typing_extensions.is_typeddict and adding tests that run key access and _isinstance with both TypedDict flavors. PR soon