`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:
co-authored by
Colby McHenry
parent
4105249843
commit
3adf06772b
@@ -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':
|
||||
|
||||
Reference in New Issue
Block a user