Skip to content

[red-knot] fix lookup of nonlocal names in deferred annotations#13236

Merged
carljm merged 2 commits intomainfrom
cjm/deferred-lookup
Sep 4, 2024
Merged

[red-knot] fix lookup of nonlocal names in deferred annotations#13236
carljm merged 2 commits intomainfrom
cjm/deferred-lookup

Conversation

@carljm
Copy link
Copy Markdown
Contributor

@carljm carljm commented Sep 3, 2024

Initially I had deferred annotation name lookups reuse the "public symbol type", since that gives the correct "from end of scope" view of reaching definitions that we want. But there is a key difference; public symbol types are based only on definitions in the queried scope (or "name in the given namespace" in runtime terms), they don't ever look up a name in nonlocal/global/builtin scopes. Deferred annotation resolution should do this lookup.

Add a test, and fix deferred name resolution to support nonlocal/global/builtin names.

Fixes #13176

@carljm carljm added the ty Multi-file analysis & type inference label Sep 3, 2024
@codspeed-hq
Copy link
Copy Markdown

codspeed-hq bot commented Sep 3, 2024

CodSpeed Performance Report

Merging #13236 will not alter performance

Comparing cjm/deferred-lookup (5260214) with main (e965f9c)

Summary

✅ 32 untouched benchmarks

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Sep 3, 2024

ruff-ecosystem results

Linter (stable)

✅ ecosystem check detected no linter changes.

Linter (preview)

✅ ecosystem check detected no linter changes.

@carljm carljm force-pushed the cjm/deferred-lookup branch from 23b23ca to 5260214 Compare September 4, 2024 16:36
@carljm carljm merged commit 66fe226 into main Sep 4, 2024
@carljm carljm deleted the cjm/deferred-lookup branch September 4, 2024 17:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ty Multi-file analysis & type inference

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[red-knot] fix deferred annotations referencing other scopes

3 participants