Skip to content

fix: validate generic TypedDict state assignments - #8019

Open
harsh21234i wants to merge 2 commits into
reflex-dev:mainfrom
harsh21234i:fix/7995-generic-typeddict-assignment
Open

harsh21234i wants to merge 2 commits into
reflex-dev:mainfrom
harsh21234i:fix/7995-generic-typeddict-assignment

Conversation

@harsh21234i

@harsh21234i harsh21234i commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Closes #7995.

  • Validate generic TypedDict fields against their specialized types in development and check the dictionary shape in production.
  • Honor postponed required and optional key annotations, and handle inherited type arguments that Python 3.11 can omit.
  • Cover standard-library and backport TypedDict classes, nested containers, and typed extra items.

Tests

  • 652 passed on Python 3.11 and 649 passed on Python 3.14 across the type, field, and state unit suites.
  • Verified state assignments in development and production, plus the reported invalid values.
  • Ruff formatting, lint, changelog validation, and git diff --check passed.

View guided diff

@harsh21234i
harsh21234i requested a review from a team as a code owner November 26, 2026 05:02
@FarhanAliRaza FarhanAliRaza added the bug Something isn't working label Nov 26, 2026 — with ChatGPT Codex Connector
@greptile-apps

greptile-apps Bot commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Confidence Score: 5/5 · The PR appears safe to merge; both previously reported assignment failures are addressed.RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; both previously reported assignment failures are addressed.

Summary

Fixes generic TypedDict assignments while preserving shallow production checks.

  • Generic TypedDict values are checked against their specialized field types.

Reviews (2) · Last reviewed commit: "Handle TypedDict validation depth, quali..." · Reviewed by Greptile

@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 3 files

Reply with feedback, questions, or to request a fix.

View guided diff | Re-trigger cubic

@codspeed

codspeed Bot commented Nov 26, 2026 •

Copy link
Copy Markdown

Merging this PR will degrade performance by 4.62%

2 warnings

⚠️ 16 benchmarks are dominated by system calls

System calls cannot be simulated consistently and are left out of the measure. The reported value understates the real cost. Switch to the Walltime instrument to measure them.

Learn more about system calls

See affected benchmarks

⚠️ 2 benchmarks with a significant change ran on different hardware

Their base and head results were measured on machines with a different CPU, core count or memory, so the changes might not come from the code. Run base and head on the same runner type.

Learn more about Macro Runners

See affected benchmarks

❌ 2 regressed benchmarks
✅ 144 untouched benchmarks
⏩ 8 skipped benchmarks1

Warning

Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Benchmark BASE HEAD Efficiency
❌ test_state_collection_assignment[10] 405.7 ms 426.1 ms -4.79%
❌ test_isinstance_scalar 78.1 ms 81.7 ms -4.45%

Tip

Investigate this regression by commenting @codspeedbot fix this regression on this PR, or directly use the CodSpeed MCP with your agent.


Comparing harsh21234i:fix/7995-generic-typeddict-assignment (22f7d14) with main (6f5c39c)

Open in CodSpeed

Footnotes

  1. 8 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩

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.

Assigning to a generic TypedDict state var crashes the handler (IndexError) or logs a false type error

2 participants