Fix Python 3.14 event handler annotation resolution - #6896
Conversation
|
Hi, I created this clean replacement PR for #6890 from the latest main branch. The previous PR included unrelated commits from #6841, so this PR contains only The Python 3.14 regression test and all 107 event unit tests pass, along with |
Merging this PR will not alter performance
Comparing Footnotes
|
Greptile SummaryThe PR caches successfully resolved state-handler annotations before runtime class patches and reuses them for event and upload validation. It also preserves retries for late-bound annotations and adds Python 3.14 regression coverage.
Confidence Score: 4/5The PR should not merge until unresolved handler annotations are protected from being retried against an already patched state-class namespace. The permanent-cache regression is fixed, but the previously reported uncached fallback remains: an initial Files Needing Attention: packages/reflex-base/src/reflex_base/event/init.py
|
| Filename | Overview |
|---|---|
| packages/reflex-base/src/reflex_base/event/init.py | Centralizes annotation resolution and caching, but the uncached unresolved-annotation fallback still permits a later retry after state-class namespace patching. |
| tests/units/test_event.py | Covers stable builtin resolution and successful late-bound retries, but not their combined sequence of initial failure followed by class patching. |
| news/6890.bugfix.md | Accurately describes the intended Python 3.14 annotation-shadowing fix. |
| packages/reflex-base/news/6890.bugfix.md | Adds the corresponding reflex-base bug-fix changelog fragment. |
Reviews (4): Last reviewed commit: "Annotate deliberate unresolved type test" | Re-trigger Greptile
There was a problem hiding this comment.
All reported issues were addressed
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
There was a problem hiding this comment.
All reported issues were addressed across 2 files (changes from recent commits).
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
Summary
Fixes #6890.
Python 3.14 evaluates deferred method annotations using the owning class
namespace. Runtime attributes on a state class can therefore shadow builtin
annotation names such as
dict.This caused valid handlers like:
def on_event(self, event: dict):
...
to fail during event argument validation.
Changes
Testing