@@ -1560,6 +1560,7 @@ impl<'db> Type<'db> {
1560
1560
Type :: Never
1561
1561
}
1562
1562
Type :: KnownInstance ( KnownInstanceType :: LiteralString ) => Type :: LiteralString ,
1563
+ Type :: KnownInstance ( KnownInstanceType :: Any ) => Type :: Any ,
1563
1564
_ => todo_type ! ( ) ,
1564
1565
}
1565
1566
}
@@ -1902,6 +1903,8 @@ pub enum KnownInstanceType<'db> {
1902
1903
NoReturn ,
1903
1904
/// The symbol `typing.Never` available since 3.11 (which can also be found as `typing_extensions.Never`)
1904
1905
Never ,
1906
+ /// The symbol `typing.Any` (which can also be found as `typing_extensions.Any`)
1907
+ Any ,
1905
1908
/// A single instance of `typing.TypeVar`
1906
1909
TypeVar ( TypeVarInstance < ' db > ) ,
1907
1910
/// A single instance of `typing.TypeAliasType` (PEP 695 type alias)
@@ -1919,6 +1922,7 @@ impl<'db> KnownInstanceType<'db> {
1919
1922
Self :: TypeVar ( _) => "TypeVar" ,
1920
1923
Self :: NoReturn => "NoReturn" ,
1921
1924
Self :: Never => "Never" ,
1925
+ Self :: Any => "Any" ,
1922
1926
Self :: TypeAliasType ( _) => "TypeAliasType" ,
1923
1927
}
1924
1928
}
@@ -1933,6 +1937,7 @@ impl<'db> KnownInstanceType<'db> {
1933
1937
| Self :: Union
1934
1938
| Self :: NoReturn
1935
1939
| Self :: Never
1940
+ | Self :: Any
1936
1941
| Self :: TypeAliasType ( _) => Truthiness :: AlwaysTrue ,
1937
1942
}
1938
1943
}
@@ -1946,6 +1951,7 @@ impl<'db> KnownInstanceType<'db> {
1946
1951
Self :: Union => "typing.Union" ,
1947
1952
Self :: NoReturn => "typing.NoReturn" ,
1948
1953
Self :: Never => "typing.Never" ,
1954
+ Self :: Any => "typing.Any" ,
1949
1955
Self :: TypeVar ( typevar) => typevar. name ( db) ,
1950
1956
Self :: TypeAliasType ( _) => "typing.TypeAliasType" ,
1951
1957
}
@@ -1960,6 +1966,7 @@ impl<'db> KnownInstanceType<'db> {
1960
1966
Self :: Union => KnownClass :: SpecialForm ,
1961
1967
Self :: NoReturn => KnownClass :: SpecialForm ,
1962
1968
Self :: Never => KnownClass :: SpecialForm ,
1969
+ Self :: Any => KnownClass :: Object ,
1963
1970
Self :: TypeVar ( _) => KnownClass :: TypeVar ,
1964
1971
Self :: TypeAliasType ( _) => KnownClass :: TypeAliasType ,
1965
1972
}
@@ -1979,6 +1986,7 @@ impl<'db> KnownInstanceType<'db> {
1979
1986
return None ;
1980
1987
}
1981
1988
match ( module. name ( ) . as_str ( ) , instance_name) {
1989
+ ( "typing" , "Any" ) => Some ( Self :: Any ) ,
1982
1990
( "typing" | "typing_extensions" , "Literal" ) => Some ( Self :: Literal ) ,
1983
1991
( "typing" | "typing_extensions" , "LiteralString" ) => Some ( Self :: LiteralString ) ,
1984
1992
( "typing" | "typing_extensions" , "Optional" ) => Some ( Self :: Optional ) ,
@@ -2647,7 +2655,11 @@ impl<'db> Class<'db> {
2647
2655
pub fn is_subclass_of ( self , db : & ' db dyn Db , other : Class ) -> bool {
2648
2656
// `is_subclass_of` is checking the subtype relation, in which gradual types do not
2649
2657
// participate, so we should not return `True` if we find `Any/Unknown` in the MRO.
2650
- self . iter_mro ( db) . contains ( & ClassBase :: Class ( other) )
2658
+ self . is_subclass_of_base ( db, other)
2659
+ }
2660
+
2661
+ fn is_subclass_of_base ( self , db : & ' db dyn Db , other : impl Into < ClassBase < ' db > > ) -> bool {
2662
+ self . iter_mro ( db) . contains ( & other. into ( ) )
2651
2663
}
2652
2664
2653
2665
/// Return the explicit `metaclass` of this class, if one is defined.
0 commit comments