Skip to content

isinstance doesn't work on type aliases that use a union #11673

@DetachHead

Description

@DetachHead
Foo = int | str

foo: object

isinstance(foo, Foo) # error
isinstance(foo, int | str) # no error

https://mypy-play.net/?mypy=master&python=3.10&gist=da37bef9ace54d59c18631a0a9f5bef2

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugmypy got something wrongtopic-pep-604PEP 604 (union | operator)topic-runtime-semanticsmypy doesn't model runtime semantics correctlytopic-type-aliasTypeAlias and other type alias issues

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions