Skip to content

fix(resolution): read a quoted Python annotation as a receiver type - #1770

Merged
colbymchenry merged 1 commit into
mainfrom
fix/1684-python-quoted-annotation-land
Sep 8, 2026
Merged

colbymchenry merged 1 commit into
mainfrom
fix/1684-python-quoted-annotation-land

Conversation

@colbymchenry

Copy link
Copy Markdown
Owner

Fixes #1684.

Problem

def f(o: "Alpha") is the same annotation as def f(o: Alpha) — a forward reference, and what every file under from __future__ import annotations writes — but the receiver-type pattern (\bo\b\s*:\s*([A-Z][\w.]*)) stopped at the quote, read no type, and o.render() produced no edge at all while the unquoted twin resolved to Alpha::render.

Change

buildLocalReceiverTypePatterns (Python) admits the quoted form, o: "Alpha" / o: 'pkg.Alpha', tried before the unquoted pattern. resolveMethodOnType still validates the method exists on that type, so nothing new can be guessed.

Evaluation of #1690

Upstream #1690 (danusha2345) had the correct fix and regression test, but was ~11 commits behind main and a full-file merge would have reverted later resolution fixes (NO_NESTED_FUNCTIONS / #1729, lexical reachability / #1708#1709). This PR lands the same surgical change on current main.

Verification (Linux)

  • Repro on main: __tests__/python-quoted-annotation.test.ts failed (expected [] to deeply equal ['Alpha::render']).
  • After fix: that test passes; __tests__/resolution.test.ts 198/198 pass.

…1684)

`def f(o: "Alpha")` is the same annotation as `def f(o: Alpha)` — a
forward reference, and what every file under `from __future__ import
annotations` writes — but the receiver-type pattern stopped at the quote,
read no type, and `o.render()` produced no edge. Admit the quoted form.
@colbymchenry
colbymchenry merged commit 3adf067 into main Sep 8, 2026
@colbymchenry
colbymchenry deleted the fix/1684-python-quoted-annotation-land branch September 8, 2026 14:30
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.

Python: a quoted forward-reference annotation (o: "Alpha") drops the call edge that the identical unquoted annotation resolves

1 participant