Skip to content

isinstance checks don't work with tuple types #2456

Closed
@JukkaL

Description

@JukkaL

An invalid type is inferred for x after isinstance in this example:

from typing import Union, Tuple

def f(x: Union[str, Tuple[str, str]]) -> None:
    if isinstance(x, tuple):
        reveal_type(x)  # Revealed type is 'builtins.None'

This was originally reported by @davire at gitter.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugmypy got something wrong

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions