Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
jolaf opened this issue Jul 5, 2022 · 1 comment
Closed

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

jolaf opened this issue Jul 5, 2022 · 1 comment
Labels
bug mypy got something wrong false-positive mypy gave an error on correct code topic-pep-604 PEP 604 (union | operator) topic-type-alias TypeAlias and other type alias issues

Comments

@jolaf
Copy link
Contributor

jolaf commented Jul 5, 2022

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
@jolaf jolaf added the bug mypy got something wrong label Jul 5, 2022
@AlexWaygood AlexWaygood added topic-pep-604 PEP 604 (union | operator) topic-pep-585 PEP 585 (builtin generics) topic-type-alias TypeAlias and other type alias issues and removed topic-pep-585 PEP 585 (builtin generics) labels Jul 5, 2022
@AlexWaygood
Copy link
Member

Duplicate of #12392

@AlexWaygood AlexWaygood marked this as a duplicate of #12392 Jul 5, 2022
@AlexWaygood AlexWaygood closed this as not planned Won't fix, can't repro, duplicate, stale Jul 5, 2022
@AlexWaygood AlexWaygood added the false-positive mypy gave an error on correct code label Jul 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug mypy got something wrong false-positive mypy gave an error on correct code topic-pep-604 PEP 604 (union | operator) topic-type-alias TypeAlias and other type alias issues
Projects
None yet
Development

No branches or pull requests

2 participants