@@ -151,6 +151,11 @@ def visit_instance(self, left: Instance) -> bool:
151
151
return all (self .check_type_parameter (lefta , righta , tvar .variance )
152
152
for lefta , righta , tvar in
153
153
zip (t .args , right .args , right .type .defn .type_vars ))
154
+ if isinstance (right , TypeType ):
155
+ item = right .item
156
+ if isinstance (item , TupleType ):
157
+ item = item .fallback
158
+ return isinstance (item , Instance ) and is_subtype (left , item .type .metaclass_type )
154
159
else :
155
160
return False
156
161
@@ -269,11 +274,13 @@ def visit_type_type(self, left: TypeType) -> bool:
269
274
if isinstance (right , CallableType ):
270
275
# This is unsound, we don't check the __init__ signature.
271
276
return right .is_type_obj () and is_subtype (left .item , right .ret_type )
272
- if (isinstance (right , Instance ) and
273
- right .type .fullname () in ('builtins.type' , 'builtins.object' )):
274
- # Treat builtins.type the same as Type[Any];
275
- # treat builtins.object the same as Any.
276
- return True
277
+ if isinstance (right , Instance ):
278
+ if right .type .fullname () in ('builtins.type' , 'builtins.object' ):
279
+ # Treat builtins.type the same as Type[Any];
280
+ # treat builtins.object the same as Any.
281
+ return True
282
+ item = left .item
283
+ return isinstance (item , Instance ) and is_subtype (item , right .type .metaclass_type )
277
284
return False
278
285
279
286
0 commit comments