Skip to content

type of variable not narrowed after continue statement inside try/except block inside a for loop inside a function #18466

Open
@DetachHead

Description

def _() -> None:
    for value in [1,2]:
        try:
            foo = 1
        except Exception:
            foo = None
            continue
        reveal_type(foo) # `int | None`, should be `int`

playground

Metadata

Assignees

No one assigned

    Labels

    bugmypy got something wrongtopic-type-narrowingConditional type narrowing / binder

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions