Skip to content

Detect illegal use of type annotation on global or nonlocal symbol #10709

@erictraut

Description

@erictraut

The use of a type annotation on a variable with global or nonlocal binding results in a "syntax error" at runtime, but pyright does not detect or report this error.

def func():
    global x
    x: str  # Runtime error

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions