@@ -291,6 +291,18 @@ def is_object(t: ProperType) -> bool:
291291 return isinstance (t , Instance ) and t .type .fullname == "builtins.object"
292292
293293
294+ def is_none_typevarlike_overlap (t1 : ProperType , t2 : ProperType ) -> bool :
295+ return isinstance (t1 , NoneType ) and isinstance (t2 , TypeVarLikeType )
296+
297+
298+ def is_none_object_overlap (t1 : ProperType , t2 : ProperType ) -> bool :
299+ return (
300+ isinstance (t1 , NoneType )
301+ and isinstance (t2 , Instance )
302+ and t2 .type .fullname == "builtins.object"
303+ )
304+
305+
294306def is_overlapping_types (
295307 left : Type ,
296308 right : Type ,
@@ -382,14 +394,6 @@ def _is_overlapping_types(left: Type, right: Type) -> bool:
382394 ):
383395 return True
384396
385- def is_none_object_overlap (t1 : Type , t2 : Type ) -> bool :
386- t1 , t2 = get_proper_types ((t1 , t2 ))
387- return (
388- isinstance (t1 , NoneType )
389- and isinstance (t2 , Instance )
390- and t2 .type .fullname == "builtins.object"
391- )
392-
393397 if overlap_for_overloads :
394398 if is_none_object_overlap (left , right ) or is_none_object_overlap (right , left ):
395399 return False
@@ -419,10 +423,6 @@ def _is_subtype(left: Type, right: Type) -> bool:
419423 # If both types are singleton variants (and are not TypeVarLikes), we've hit the base case:
420424 # we skip these checks to avoid infinitely recursing.
421425
422- def is_none_typevarlike_overlap (t1 : Type , t2 : Type ) -> bool :
423- t1 , t2 = get_proper_types ((t1 , t2 ))
424- return isinstance (t1 , NoneType ) and isinstance (t2 , TypeVarLikeType )
425-
426426 if prohibit_none_typevar_overlap :
427427 if is_none_typevarlike_overlap (left , right ) or is_none_typevarlike_overlap (right , left ):
428428 return False
0 commit comments