8000 F821 with Annotated import alias · Issue #789 · PyCQA/pyflakes · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
F821 with Annotated import alias #789
Open
@alanhdu

Description

@alanhdu

We have a use-case where we sometimes import Annotated under a different name (since there is a naming collision with an existing object callled Annotations and Annotated[Annotations, ...] can be hard to read. Unfortunately, it looks like if we try to do this, then we fail with a false positive:

from typing_extensions import Annotated as WithSchema


def f(x: WithSchema[int, "hello"]) -> None:
    return

fails pyflakes with F821 undefined name 'hello.

Everything works fine if we do not use the Annotated as WithSchema import alias though. Would it be possible to extend the logic to also handle such a case?

cc @nishkakar @ezrilow

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0