mypy
mypy copied to clipboard
`Value of type "Type[type]" is not indexable` error inside `reveal_type(type[type])`
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
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.
Also this:
type[int](1) # error: Value of type "Type[type]" is not indexable
Also this:
a: object = type[int]