Skip to content

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

Open
benedikt-bartscher wants to merge 2 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 2 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 consolidates event callback type-hint resolution.

  • Adds annotation-name probing across a class MRO.
  • Gates full type-hint resolution on whether the requested attribute is annotated.
  • Adds regression coverage for unresolved and Python 3.14 lazy annotations.
  • Extracts the event callback type-hint fallback into a shared helper.

Confidence Score: 4/5

The PR is not yet safe to merge because the annotation-name cache can reject attributes added after its first snapshot.

The cached MRO annotation-name set is never refreshed, so a later class annotation remains invisible to the new gate and ObjectVar attribute access raises 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 remains stale after class annotation mutation.
packages/reflex-base/src/reflex_base/utils/types.py Uses annotation-name discovery to avoid unnecessary ForwardRef resolution, while relying on the potentially stale cached result.
packages/reflex-base/src/reflex_base/event/init.py Extracts the existing NameError fallback for callback type-hint resolution into a shared helper.
tests/units/test_attribute_access_type.py Covers unannotated probes, unresolved annotations, and Python 3.14 lazy annotations, but does not cover annotation mutation after an initial probe.

Reviews (2): Last reviewed commit: "fix: actually test it for python3.14" | 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 (a6b988d) with main (d86f167)

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