Skip to content

fix(analyzer): support member access on Annotated alias values - #11691

Open
Henry Su (hsusul) wants to merge 1 commit into
microsoft:mainfrom
hsusul:fix/annotated-alias-member-access
Open

fix(analyzer): support member access on Annotated alias values#11691
Henry Su (hsusul) wants to merge 1 commit into
microsoft:mainfrom
hsusul:fix/annotated-alias-member-access

Conversation

@hsusul

Copy link
Copy Markdown
Contributor

Closes #11538.

Summary of Changes

At runtime, typing._AnnotatedAlias.__getattr__ delegates attribute access to __origin__ (the underlying annotated type).

In getTypeOfMemberAccessWithBaseType:

  • Preserved baseType.props?.typeForm as baseTypeForm before stripping special forms.
  • When member lookup on an Annotated special form produces an error or no member, falls back to evaluating member access against the underlying typeForm.
  • Added sample test annotated10.py and test suite entry in typeEvaluator7.test.ts verifying member access on an Annotated alias value.

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.
@bschnurr

Bill Schnurr (bschnurr) commented Sep 1, 2026

Copy link
Copy Markdown
Member

🔒 Automated review in progress — Bill Schnurr (@bschnurr) is auto-reviewing this PR.

@bschnurr

Copy link
Copy Markdown
Member

Verification: The relevant tests could not be fully run in the isolated environment; this review is not fully verified.

Result: could-not-verify

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

  • ⚠️ Not run | Dependency and test discovery | git status --short && git diff --name-status upstream/main...HEAD && git diff --stat upstream/main...HEAD && if [ -d packages/pyright-internal/node_modules ]; then echo DEPS_PRESENT; else echo DEPS_MISSING; fi && node -e "const p=require('./packages/pyright-internal/package.json'); console.log(JSON.stringify(p.scripts))"
  • ⚠️ Not run | Annotated10 | node ./node_modules/jest/bin/jest.js typeEvaluator7.test -t Annotated10 --runInBand
⚠️ Dependency and test discovery diagnostic output
Container verification could not start: no trusted sandbox image is configured for microsoft/pyright.
⚠️ Annotated10 diagnostic output
Not attempted after the verification container failed to start.

@bschnurr Bill Schnurr (bschnurr) left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved via Review Center.

@bschnurr Bill Schnurr (bschnurr) added the review-auto:approved Automated review: no blocking findings (approval posted). label Sep 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

review-auto:approved Automated review: no blocking findings (approval posted).

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Member access on an Annotated alias value is rejected (unlike __getitem__, cf #8916)

2 participants