Skip to content

Invalid type for redefined variable inside nested function #7984

Open
@JukkaL

Description

@JukkaL

The revealed type in this example is int, even though it should be str:

# mypy: allow-redefinition

def f() -> None:
    x = 0
    print(x)
    x = 'x'

    def g() -> None:
        reveal_type(x)  # int, but should be str

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions