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
Key access on a subclass of a specialized generic TypedDict fails with Unsupported type ~T #7997
#7887 made key access work on a parametrized generic TypedDict (p: P[int]). A subclass of a specialized generic TypedDict still fails at compile time:
TypeError: Unsupported type ~T for guess_type.
get_attribute_access_type (utils/types.py) handles the class as a bare class and reads its annotations with get_type_hints. The annotations of a subclass of P[str] still contain the unbound T, so the var type becomes ~T. get_typed_dict_field_types(R) already resolves the field correctly to {'value': str}, but the bare-class branch does not use it.
Repro
fromtypingimportGeneric, TypedDict, TypeVarimportreflexasrxT=TypeVar("T")
classP(TypedDict, Generic[T]):
value: TclassR(P[str]):
passclassState(rx.State):
r: R= {"value": "a"}
State.r["value"] # TypeError: Unsupported type ~T for guess_type.
State.r["value"] is typed str, as State.p["value"] is for p: P[str].
Fix direction
In get_attribute_access_type, resolve the field type of every TypedDict, bare class or alias, through get_typed_dict_field_types. That helper has no cache, and a bare-class lookup with it takes about 12 µs instead of about 0.6 µs (measured during the #7887 review). So add a cache to the helper, or use it only when get_type_hints returns a TypeVar.
The comment at utils/types.py:1115 (_get_column_access_type) still says that the keys of a parametrized generic TypedDict "are not resolved". That is not true after #7887. Update the comment in the same change.
Activity
linear-code commentedon Nov 25, 2026
ENG-14948