@@ -7984,20 +7984,22 @@ def get_type_range_of_type(self, typ: Type) -> TypeRange | None:
79847984 # except for Type[None], because "'NoneType' is not an acceptable base type"
79857985 is_upper_bound = False
79867986 return TypeRange (typ .item , is_upper_bound = is_upper_bound )
7987+ if isinstance (typ , AnyType ):
7988+ return TypeRange (typ , is_upper_bound = False )
79877989 if isinstance (typ , Instance ) and typ .type .fullname == "builtins.type" :
79887990 object_type = Instance (typ .type .mro [- 1 ], [])
79897991 return TypeRange (object_type , is_upper_bound = True )
79907992 if isinstance (typ , Instance ) and typ .type .fullname == "types.UnionType" and typ .args :
79917993 return TypeRange (UnionType (typ .args ), is_upper_bound = False )
7992- if isinstance (typ , AnyType ) :
7993- return TypeRange ( typ , is_upper_bound = False )
7994- if not is_subtype ( self . named_type ( "builtins.type" ), typ ) and not (
7995- isinstance ( typ , Instance ) and typ . type . fullname == "typing._SpecialForm"
7996- ):
7994+ if isinstance (typ , Instance ) and typ . type . fullname == "typing._SpecialForm" :
7995+ # This is probably an alias to a Union object. We don't have the args here so we can't
7996+ # conclude anything
7997+ return None
7998+ if not is_subtype ( self . named_type ( "builtins.type" ), typ ):
79977999 # We saw something, but it couldn't possibly be valid
79988000 return TypeRange (UninhabitedType (), is_upper_bound = False )
79998001
8000- # Here we e.g. saw a variable with unknown value
8002+ # This is e.g. a variable of type object, so we can't conclude anything
80018003 return None
80028004
80038005 def is_literal_enum (self , n : Expression ) -> bool :
0 commit comments