Skip to content

Type not narrowed correctly for if X in collection #3229

Open
@frexvahi

Description

@frexvahi
def foobar(foo: Union[str, float]):
    if foo in ['fizz', 'buzz']:
        reveal_type(foo)
    else:
        pass

The revealed type is Union[builtins.str, builtins.float] but should be builtins.str

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions