Skip to content
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

Value of type "Type[type]" is not indexable error inside reveal_type(type[type]) #13026

Open
denballakh opened this issue Jun 26, 2022 · 3 comments
Labels
bug mypy got something wrong false-positive mypy gave an error on correct code topic-pep-585 PEP 585 (builtin generics)

Comments

@denballakh
Copy link
Contributor

When type[type] is used inside reveal_type() i get Value of type "Type[type]" is not indexable error:

reveal_type(type[type]) # Value of type "Type[type]" is not indexable
                        # Revealed type is "Any"

Expected Behavior
I expect behavior similar to this example:

X: type[type[type]]
reveal_type(X) # Revealed type is "Type[Type[builtins.type]]"

So i expect this:

reveal_type(type[type]) # Revealed type is "Type[Type[builtins.type]]"

My Environment

  • mypy 0.961 (compiled: no)
  • no command-line flags, no config file
  • CPython 3.10.4
  • Windows 10
@denballakh denballakh added the bug mypy got something wrong label Jun 26, 2022
@AlexWaygood
Copy link
Member

It's the same bug as this: #12392 (I guess this isn't, strictly speaking, a duplicate, however). The underlying issue is that mypy still struggles with type[T] being used in runtime contexts.

@AlexWaygood AlexWaygood added topic-pep-585 PEP 585 (builtin generics) false-positive mypy gave an error on correct code labels Jun 26, 2022
@KotlinIsland
Copy link
Contributor

Also this:

type[int](1)  # error: Value of type "Type[type]" is not indexable

@KotlinIsland
Copy link
Contributor

Also this:

a: object = type[int]

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-585 PEP 585 (builtin generics)
Projects
None yet
Development

No branches or pull requests

3 participants