Skip to content

(🐞) isinstance works with typing.Unions on 3.10+ #7505

Closed as not planned
Closed as not planned
@KotlinIsland

Description

@KotlinIsland
from typing import Union

print(isinstance(1, Union[str, int]))  # error: Argument 2 to "isinstance" has incompatible type "object"; expected "Union[type, UnionType, Tuple[Union[type, UnionType, Tuple[Any, ...]], ...]]"

But this outputs True

Union[X, Y] is stubbed to return object when it really returns a typing._UnionGenericAlias to typing.Union so that would need to be fixed first.

playground

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions