KEMBAR78
(🐞) `isinstance` doesn't work with unions containing `None` · Issue #17413 · python/mypy · GitHub
Skip to content

(🐞) isinstance doesn't work with unions containing None #17413

@KotlinIsland

Description

@KotlinIsland
value: str | bool | None
assert not isinstance(value, str | None)
reveal_type(value)  # str | bool | None
value: object
assert isinstance(value, str | None)
reveal_type(value)  # object

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