Inconsistent narrowing for builtins.type
and typing.Type
#16349
Labels
bug
mypy got something wrong
topic-pep-585
PEP 585 (builtin generics)
topic-type-narrowing
Conditional type narrowing / binder
The following difference is due to Mypy handling
typing.Type
viaTypeType
, for which it does not try to create an intersection, andbuiltins.type
as anInstance
, for which it does:I encountered this problem when working on #16330, which affects type checking a sphinx function.
Interestingly, things are consistent when annotating explicitly with
Any
:So, Mypy maybe misunderstands
t2: type
?The text was updated successfully, but these errors were encountered: