Skip to content

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

Open
benedikt-bartscher wants to merge 4 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 4 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

The PR avoids resolving unrelated forward references when probing unannotated attributes.

  • Adds an annotation-name check across a class MRO before calling get_type_hints.
  • Handles Python 3.14 lazy annotations through annotationlib.
  • Adds regression coverage for unannotated probes, unresolved annotations, and PEP 649 behavior.
  • Adds a bugfix news entry.

Confidence Score: 4/5

The PR is not yet safe to merge because the annotation-name snapshot remains stale when annotations change after the first probe.

The cached MRO annotation names have no invalidation path, while get_attribute_access_type now relies on that snapshot to decide whether an annotated attribute can be resolved.

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

Important Files Changed

Filename Overview
packages/reflex-base/src/reflex_base/utils/compat.py Adds MRO-wide annotation-name discovery with Python 3.14 lazy-annotation support.
packages/reflex-base/src/reflex_base/utils/types.py Gates type-hint resolution on whether the requested attribute is declared in the class MRO.
tests/units/test_attribute_access_type.py Adds regression tests for unannotated probes, unresolved forward references, and Python 3.14 lazy annotations.
packages/reflex-base/news/+annotation-probe-guard.bugfix.md Documents the attribute-probe and lazy-annotation fix.

Reviews (4): Last reviewed commit: "Merge remote-tracking branch 'upstream/m..." | 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 (dc3bc6a) with main (f7c848f)2

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.

  2. No successful run was found on main (45b8ed5) during the generation of this report, so f7c848f was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

@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