Skip to content

Prohibit use of names in annotations that are undefined in runtime #3088

@pkch

Description

@pkch

This type checks, but crashes in runtime with NameError:

class A:
    def f(x: A) -> None:
        pass

I think it's better if mypy reported an error Name "A" should be a forward reference.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions