Skip to content

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

Open
danusha2345 wants to merge 1 commit into
colbymchenry:mainfrom
danusha2345:fix/1684-python-quoted-annotation
Open

fix(resolution): read a quoted Python annotation as a receiver type#1690
danusha2345 wants to merge 1 commit into
colbymchenry:mainfrom
danusha2345:fix/1684-python-quoted-annotation

Conversation

@danusha2345

Copy link
Copy Markdown
Contributor

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.

Verification

New __tests__/python-quoted-annotation.test.ts with the issue's repro: quoted, single-quoted and unquoted annotations all resolve to the same method; it fails on main (expected [] to deeply equal ['Alpha::render']). Full suite green.

🤖 Generated with Claude Code

…olbymchenry#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 at all. Admit the quoted
form.
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