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

`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.

Co-authored-by: Colby McHenry <colbymchenry@users.noreply.github.com>
This commit is contained in:
Colby Mchenry
2026-09-08 09:30:01 -05:00
committed by GitHub
co-authored by Colby McHenry
parent 4105249843
commit 3adf06772b
3 changed files with 62 additions and 0 deletions
+6
View File
@@ -1697,6 +1697,12 @@ function buildLocalReceiverTypePatterns(language: Language, r: string): RegExp[]
case 'python':
return [
new RegExp(`\\b${r}\\b\\s*=\\s*([A-Z][\\w.]*)\\s*\\(`), // lg = Logger(...)
// A quoted forward reference (`lg: "Logger"`, `lg: 'pkg.Logger'`) is the
// same annotation — and what every file under `from __future__ import
// annotations` or with a not-yet-defined class writes. The unquoted
// pattern below stopped at the quote and read no type at all, so the
// call produced no edge (#1684). Tried first: it is the stricter shape.
new RegExp(`\\b${r}\\b\\s*:\\s*["']([A-Z][\\w.]*)["']`), // lg: "Logger"
new RegExp(`\\b${r}\\b\\s*:\\s*([A-Z][\\w.]*)`), // lg: Logger (PEP 526)
];
case 'java':