Skip to content

fix(types): skip ForwardRef resolution for unannotated attribute probes - #6929

Open
benedikt-bartscher wants to merge 3 commits into
reflex-dev:mainfrom
benedikt-bartscher:annotation-probe-guard
Open

fix(types): skip ForwardRef resolution for unannotated attribute probes#6929
benedikt-bartscher wants to merge 3 commits into
reflex-dev:mainfrom
benedikt-bartscher:annotation-probe-guard

Conversation

@benedikt-bartscher

@benedikt-bartscher benedikt-bartscher commented Aug 22, 2026

Copy link
Copy Markdown
Contributor

Review in cubic

@greptile-apps

greptile-apps Bot commented Aug 22, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR avoids resolving unrelated forward references during unannotated attribute probes and centralizes tolerant event-callback type-hint lookup.

  • Adds annotation-name probing across a class MRO before resolving full type hints.
  • Adds Python 3.14 coverage for PEP 649 lazy annotations.
  • Reuses a helper for callback annotations containing unresolved forward references.

Confidence Score: 4/5

The PR is not yet safe to merge because the outstanding annotation-name cache can reject valid attributes after class annotations change.

The cache snapshots annotation names without invalidation, while attribute access relies on that cached membership check before resolving hints; a later-added annotation can therefore still produce VarAttributeError.

Files Needing Attention: packages/reflex-base/src/reflex_base/utils/compat.py and packages/reflex-base/src/reflex_base/utils/types.py

Important Files Changed

Filename Overview
packages/reflex-base/src/reflex_base/utils/compat.py Adds cached MRO annotation-name discovery, but the cache still permanently misses annotations added after its first lookup.
packages/reflex-base/src/reflex_base/utils/types.py Gates full type-hint resolution on declared annotation names to prevent unrelated forward-reference evaluation.
packages/reflex-base/src/reflex_base/event/init.py Deduplicates existing unresolved-ForwardRef handling into a shared helper.
tests/units/test_attribute_access_type.py Adds coverage for unannotated probes, unresolved annotations, and Python 3.14 lazy annotations.

Reviews (3): Last reviewed commit: "Merge branch 'main' into annotation-prob..." | Re-trigger Greptile

Comment thread packages/reflex-base/src/reflex_base/utils/compat.py
@codspeed-hq

codspeed-hq Bot commented Aug 22, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 27 untouched benchmarks
⏩ 8 skipped benchmarks1


Comparing benedikt-bartscher:annotation-probe-guard (74a51dc) with main (126ef6d)

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.

@benedikt-bartscher
benedikt-bartscher marked this pull request as ready for review August 22, 2026 12:41
@benedikt-bartscher
benedikt-bartscher requested a review from a team as a code owner August 22, 2026 12:41

@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

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

Re-trigger cubic

Comment thread tests/units/test_attribute_access_type.py Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant