Skip to content

Type[type] is not indexable when in Union #13074

Closed as not planned
Closed as not planned
@jolaf

Description

@jolaf

The following code:

t = type[str] | type[bytes]

produces the following output:

$ mypy test.py
test.py:1:5: error: Value of type "Type[type]" is not indexable  [index]
    t = type[str] | type[bytes]
        ^
Found 1 error in 1 file (checked 1 source file)

This looks like a false positive to me.

$ mypy --version
mypy 0.961 (compiled: yes)

$ python3 --version
Python 3.10.4

$ lsb_release -d
Description:	Ubuntu 22.04 LTS

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugmypy got something wrongfalse-positivemypy gave an error on correct codetopic-pep-604PEP 604 (union | operator)topic-type-aliasTypeAlias and other type alias issues

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions