Skip to content

fix(vars): treat typing_extensions TypedDict state vars as TypedDicts - #8024

Open
cestercian wants to merge 2 commits into
reflex-dev:mainfrom
cestercian:fix/typing-extensions-typeddict
Open

cestercian wants to merge 2 commits into
reflex-dev:mainfrom
cestercian:fix/typing-extensions-typeddict

Conversation

@cestercian

@cestercian cestercian commented Nov 26, 2026 •

Copy link
Copy Markdown

All Submissions:

  • Have you followed the guidelines stated in CONTRIBUTING.md file?
  • Have you checked to ensure there aren't any other open Pull Requests for the desired changed?

Type of change

  • Bug fix (non-breaking change which fixes an issue)

Changes To Core Features:

  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your core changes, as applicable?
  • Have you successfully ran tests with your changes locally?

Fixes #7996

vars/object.py and utils/types.py imported is_typeddict from typing, which returns False for typing_extensions.TypedDict classes on 3.11+ with typing_extensions 4.16. So a var typed with one had Any keys, no error on unknown keys, and _isinstance didn't check the fields. Both modules now use typing_extensions.is_typeddict, which handles both flavors. types.py already called typing_extensions.is_typeddict in a few places, so those now just use the imported name.

Tests:

  • test_typed_dict_key_access runs key access with a typing.TypedDict and a typing_extensions.TypedDict (field types plus VarAttributeError for a missing key)
  • test_isinstance_typing_extensions_typed_dict checks _isinstance against a typing_extensions.TypedDict

The new tests fail on main and pass with the change. ruff and pyright are clean on the touched files. The full unit suite has the same 255 failures on main and on this branch here (mostly tests/units/reflex_cli, environment related), nothing new.

View guided diff

@cestercian
cestercian requested a review from a team as a code owner November 26, 2026 15:25
@FarhanAliRaza FarhanAliRaza added the bug Something isn't working label Nov 26, 2026 — with ChatGPT Codex Connector

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 5 files

Tip: Get a Slack DM when cubic finishes reviewing your PRs. Connect Slack

View guided diff | Re-trigger cubic

@greptile-apps

greptile-apps Bot commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Confidence Score: 4/5 · The PR still needs the earlier fix for known TypedDict fields becoming unreadable when another annotation cannot be resolved.RetriggerView in GreptileConfidence Score: 4/5

[Medium impact] The change affects TypedDict state access and value checks in Reflex.

The PR still needs the earlier fix for known TypedDict fields becoming unreadable when another annotation cannot be resolved.

Findings

  1. P1 Known fields become unreadable ▶

Summary

Recognizes both typing.TypedDict and typing_extensions.TypedDict in object vars and type checks.

  • State vars use field types with either TypedDict form.

Reviews (2) · Last reviewed commit: "address review: use get_typed_dict_field..." · Reviewed by Greptile

)
from typing import Any, NoReturn, TypeVar, get_args, get_type_hints, overload

from typing_extensions import is_typeddict

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Known fields become unreadable

The new import sends bare typing_extensions.TypedDict fields through get_attribute_access_type, which resolves every annotation at once. If one field names a type imported only under TYPE_CHECKING, reading even a different, fully defined field now raises VarAttributeError. Previously that read returned an Any-typed var, so this can break existing app expressions.

Use get_typed_dict_field_types for TypedDict field lookup. It already keeps known field types and treats unresolved names as Any.

Comment thread tests/units/utils/test_types.py Resolved

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

typing_extensions.TypedDict state vars have untyped keys because typing.is_typeddict returns False

2 participants