Skip to content

(🐞) | operator with _SpecialForm determined to be types.UnionType it's actually typing.Union #12369

Open
@KotlinIsland

Description

@KotlinIsland
from typing import Any

print(reveal_type(int | Any))  #  types.UnionType
> python test.py
typing.Union[int, typing.Any]

This causes issues with isinstance, despite the fact that isinstance can take a typing.Union.

from typing import Any

isinstance(1, str | Any)  # no error

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugmypy got something wrongtopic-pep-604PEP 604 (union | operator)

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions