fix(analyzer): support member access on Annotated alias values - #11691
Open
Henry Su (hsusul) wants to merge 1 commit into
Open
fix(analyzer): support member access on Annotated alias values#11691Henry Su (hsusul) wants to merge 1 commit into
Henry Su (hsusul) wants to merge 1 commit into
Conversation
At runtime, typing._AnnotatedAlias delegates attribute access to __origin__ (the annotated type). When member access on an Annotated special form fails, fall back to evaluating member access on its underlying typeForm.
Member
|
🔒 Automated review in progress — Bill Schnurr (@bschnurr) is auto-reviewing this PR. |
Member
|
Verification: The relevant tests could not be fully run in the isolated environment; this review is not fully verified. Result: Summary: No tests executed because the verification container could not start: no trusted sandbox image is configured for `microsoft/pyright`. The PR adds the targeted `Annotated10` Jest case covering member access through an `Annotated` alias. Verification is therefore blocked by the environment. Test runs: 2 not run
|
Bill Schnurr (bschnurr)
approved these changes
Sep 1, 2026
Bill Schnurr (bschnurr)
left a comment
Member
There was a problem hiding this comment.
Approved via Review Center.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #11538.
Summary of Changes
At runtime,
typing._AnnotatedAlias.__getattr__delegates attribute access to__origin__(the underlying annotated type).In
getTypeOfMemberAccessWithBaseType:baseType.props?.typeFormasbaseTypeFormbefore stripping special forms.Annotatedspecial form produces an error or no member, falls back to evaluating member access against the underlyingtypeForm.annotated10.pyand test suite entry intypeEvaluator7.test.tsverifying member access on anAnnotatedalias value.