Skip to content

[red-knot] fix deferred annotations referencing other scopes #13176

@carljm

Description

@carljm

Our current handling for resolving deferred annotations uses the inferred types of symbols as they exist at the end of the current scope (rather than the current point in control flow of the current scope), which is correct (or at least the most reasonable option) since their resolution is deferred.

But it currently does this by piggy-backing on the same logic we use for e.g. import resolution, where the name must exist in the scope's namespace, there's no fallback to other scopes. So we can't resolve a deferred annotation that's a builtin, or a global or nonlocal referred to from a nested scope. This should be fixed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingtyMulti-file analysis & type inference

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions