@@ -562,25 +562,22 @@ impl<'db> Type<'db> {
562562
563563 fn is_none ( & self , db : & ' db dyn Db ) -> bool {
564564 self . into_nominal_instance ( )
565- . is_some_and ( |instance| instance. class ( ) . is_known ( db, KnownClass :: NoneType ) )
565+ . is_some_and ( |instance| instance. class . is_known ( db, KnownClass :: NoneType ) )
566566 }
567567
568568 fn is_bool ( & self , db : & ' db dyn Db ) -> bool {
569569 self . into_nominal_instance ( )
570- . is_some_and ( |instance| instance. class ( ) . is_known ( db, KnownClass :: Bool ) )
570+ . is_some_and ( |instance| instance. class . is_known ( db, KnownClass :: Bool ) )
571571 }
572572
573573 pub fn is_notimplemented ( & self , db : & ' db dyn Db ) -> bool {
574- self . into_nominal_instance ( ) . is_some_and ( |instance| {
575- instance
576- . class ( )
577- . is_known ( db, KnownClass :: NotImplementedType )
578- } )
574+ self . into_nominal_instance ( )
575+ . is_some_and ( |instance| instance. class . is_known ( db, KnownClass :: NotImplementedType ) )
579576 }
580577
581578 pub fn is_object ( & self , db : & ' db dyn Db ) -> bool {
582579 self . into_nominal_instance ( )
583- . is_some_and ( |instance| instance. class ( ) . is_object ( db) )
580+ . is_some_and ( |instance| instance. class . is_object ( db) )
584581 }
585582
586583 pub const fn is_todo ( & self ) -> bool {
@@ -1063,7 +1060,7 @@ impl<'db> Type<'db> {
10631060 ( _, Type :: Never ) => false ,
10641061
10651062 // Everything is a subtype of `object`.
1066- ( _, Type :: NominalInstance ( instance) ) if instance. class ( ) . is_object ( db) => true ,
1063+ ( _, Type :: NominalInstance ( instance) ) if instance. class . is_object ( db) => true ,
10671064
10681065 // In general, a TypeVar `T` is not a subtype of a type `S` unless one of the two conditions is satisfied:
10691066 // 1. `T` is a bound TypeVar and `T`'s upper bound is a subtype of `S`.
@@ -1373,7 +1370,7 @@ impl<'db> Type<'db> {
13731370
13741371 // All types are assignable to `object`.
13751372 // TODO this special case might be removable once the below cases are comprehensive
1376- ( _, Type :: NominalInstance ( instance) ) if instance. class ( ) . is_object ( db) => true ,
1373+ ( _, Type :: NominalInstance ( instance) ) if instance. class . is_object ( db) => true ,
13771374
13781375 // In general, a TypeVar `T` is not assignable to a type `S` unless one of the two conditions is satisfied:
13791376 // 1. `T` is a bound TypeVar and `T`'s upper bound is assignable to `S`.
@@ -1547,7 +1544,7 @@ impl<'db> Type<'db> {
15471544 }
15481545
15491546 ( Type :: NominalInstance ( instance) , Type :: Callable ( _) )
1550- if instance. class ( ) . is_subclass_of_any_or_unknown ( db) =>
1547+ if instance. class . is_subclass_of_any_or_unknown ( db) =>
15511548 {
15521549 true
15531550 }
@@ -1616,7 +1613,7 @@ impl<'db> Type<'db> {
16161613 }
16171614 ( Type :: ProtocolInstance ( protocol) , nominal @ Type :: NominalInstance ( n) )
16181615 | ( nominal @ Type :: NominalInstance ( n) , Type :: ProtocolInstance ( protocol) ) => {
1619- n. class ( ) . is_object ( db) && protocol. normalized ( db) == nominal
1616+ n. class . is_object ( db) && protocol. normalized ( db) == nominal
16201617 }
16211618 _ => self == other && self . is_fully_static ( db) && other. is_fully_static ( db) ,
16221619 }
@@ -1671,7 +1668,7 @@ impl<'db> Type<'db> {
16711668 }
16721669 ( Type :: ProtocolInstance ( protocol) , nominal @ Type :: NominalInstance ( n) )
16731670 | ( nominal @ Type :: NominalInstance ( n) , Type :: ProtocolInstance ( protocol) ) => {
1674- n. class ( ) . is_object ( db) && protocol. normalized ( db) == nominal
1671+ n. class . is_object ( db) && protocol. normalized ( db) == nominal
16751672 }
16761673 _ => false ,
16771674 }
@@ -1883,7 +1880,7 @@ impl<'db> Type<'db> {
18831880 // member on `protocol`.
18841881 ( Type :: ProtocolInstance ( protocol) , nominal @ Type :: NominalInstance ( n) )
18851882 | ( nominal @ Type :: NominalInstance ( n) , Type :: ProtocolInstance ( protocol) ) => {
1886- n. class ( ) . is_final ( db) && !nominal. satisfies_protocol ( db, protocol)
1883+ n. class . is_final ( db) && !nominal. satisfies_protocol ( db, protocol)
18871884 }
18881885
18891886 (
@@ -1948,7 +1945,7 @@ impl<'db> Type<'db> {
19481945
19491946 ( Type :: KnownInstance ( known_instance) , Type :: NominalInstance ( instance) )
19501947 | ( Type :: NominalInstance ( instance) , Type :: KnownInstance ( known_instance) ) => {
1951- !known_instance. is_instance_of ( db, instance. class ( ) )
1948+ !known_instance. is_instance_of ( db, instance. class )
19521949 }
19531950
19541951 ( known_instance_ty @ Type :: KnownInstance ( _) , Type :: Tuple ( tuple) )
@@ -1960,7 +1957,7 @@ impl<'db> Type<'db> {
19601957 | ( Type :: NominalInstance ( instance) , Type :: BooleanLiteral ( ..) ) => {
19611958 // A `Type::BooleanLiteral()` must be an instance of exactly `bool`
19621959 // (it cannot be an instance of a `bool` subclass)
1963- !KnownClass :: Bool . is_subclass_of ( db, instance. class ( ) )
1960+ !KnownClass :: Bool . is_subclass_of ( db, instance. class )
19641961 }
19651962
19661963 ( Type :: BooleanLiteral ( ..) , _) | ( _, Type :: BooleanLiteral ( ..) ) => true ,
@@ -1969,7 +1966,7 @@ impl<'db> Type<'db> {
19691966 | ( Type :: NominalInstance ( instance) , Type :: IntLiteral ( ..) ) => {
19701967 // A `Type::IntLiteral()` must be an instance of exactly `int`
19711968 // (it cannot be an instance of an `int` subclass)
1972- !KnownClass :: Int . is_subclass_of ( db, instance. class ( ) )
1969+ !KnownClass :: Int . is_subclass_of ( db, instance. class )
19731970 }
19741971
19751972 ( Type :: IntLiteral ( ..) , _) | ( _, Type :: IntLiteral ( ..) ) => true ,
@@ -1981,7 +1978,7 @@ impl<'db> Type<'db> {
19811978 | ( Type :: NominalInstance ( instance) , Type :: StringLiteral ( ..) | Type :: LiteralString ) => {
19821979 // A `Type::StringLiteral()` or a `Type::LiteralString` must be an instance of exactly `str`
19831980 // (it cannot be an instance of a `str` subclass)
1984- !KnownClass :: Str . is_subclass_of ( db, instance. class ( ) )
1981+ !KnownClass :: Str . is_subclass_of ( db, instance. class )
19851982 }
19861983
19871984 ( Type :: LiteralString , Type :: LiteralString ) => false ,
@@ -1991,7 +1988,7 @@ impl<'db> Type<'db> {
19911988 | ( Type :: NominalInstance ( instance) , Type :: BytesLiteral ( ..) ) => {
19921989 // A `Type::BytesLiteral()` must be an instance of exactly `bytes`
19931990 // (it cannot be an instance of a `bytes` subclass)
1994- !KnownClass :: Bytes . is_subclass_of ( db, instance. class ( ) )
1991+ !KnownClass :: Bytes . is_subclass_of ( db, instance. class )
19951992 }
19961993
19971994 // A class-literal type `X` is always disjoint from an instance type `Y`,
@@ -2012,7 +2009,7 @@ impl<'db> Type<'db> {
20122009 | ( Type :: NominalInstance ( instance) , Type :: FunctionLiteral ( ..) ) => {
20132010 // A `Type::FunctionLiteral()` must be an instance of exactly `types.FunctionType`
20142011 // (it cannot be an instance of a `types.FunctionType` subclass)
2015- !KnownClass :: FunctionType . is_subclass_of ( db, instance. class ( ) )
2012+ !KnownClass :: FunctionType . is_subclass_of ( db, instance. class )
20162013 }
20172014
20182015 ( Type :: BoundMethod ( _) , other) | ( other, Type :: BoundMethod ( _) ) => KnownClass :: MethodType
@@ -2440,7 +2437,7 @@ impl<'db> Type<'db> {
24402437 // i.e. Type::NominalInstance(type). So looking up a name in the MRO of
24412438 // `Type::NominalInstance(type)` is equivalent to looking up the name in the
24422439 // MRO of the class `object`.
2443- Type :: NominalInstance ( instance) if instance. class ( ) . is_known ( db, KnownClass :: Type ) => {
2440+ Type :: NominalInstance ( instance) if instance. class . is_known ( db, KnownClass :: Type ) => {
24442441 KnownClass :: Object
24452442 . to_class_literal ( db)
24462443 . find_name_in_mro_with_policy ( db, name, policy)
@@ -2530,7 +2527,7 @@ impl<'db> Type<'db> {
25302527
25312528 Type :: Dynamic ( _) | Type :: Never => Symbol :: bound ( self ) . into ( ) ,
25322529
2533- Type :: NominalInstance ( instance) => instance. class ( ) . instance_member ( db, name) ,
2530+ Type :: NominalInstance ( instance) => instance. class . instance_member ( db, name) ,
25342531
25352532 Type :: ProtocolInstance ( protocol) => protocol. instance_member ( db, name) ,
25362533
@@ -2978,7 +2975,7 @@ impl<'db> Type<'db> {
29782975
29792976 Type :: NominalInstance ( instance)
29802977 if matches ! ( name. as_str( ) , "major" | "minor" )
2981- && instance. class ( ) . is_known ( db, KnownClass :: VersionInfo ) =>
2978+ && instance. class . is_known ( db, KnownClass :: VersionInfo ) =>
29822979 {
29832980 let python_version = Program :: get ( db) . python_version ( db) ;
29842981 let segment = if name == "major" {
@@ -3050,7 +3047,7 @@ impl<'db> Type<'db> {
30503047 // resolve the attribute.
30513048 if matches ! (
30523049 self . into_nominal_instance( )
3053- . and_then( |instance| instance. class( ) . known( db) ) ,
3050+ . and_then( |instance| instance. class. known( db) ) ,
30543051 Some ( KnownClass :: ModuleType | KnownClass :: GenericAlias )
30553052 ) {
30563053 return Symbol :: Unbound . into ( ) ;
@@ -3309,7 +3306,7 @@ impl<'db> Type<'db> {
33093306 }
33103307 } ,
33113308
3312- Type :: NominalInstance ( instance) => match instance. class ( ) . known ( db) {
3309+ Type :: NominalInstance ( instance) => match instance. class . known ( db) {
33133310 Some ( known_class) => known_class. bool ( ) ,
33143311 None => try_dunder_bool ( ) ?,
33153312 } ,
@@ -4863,7 +4860,7 @@ impl<'db> Type<'db> {
48634860
48644861 Type :: Dynamic ( _) => Ok ( * self ) ,
48654862
4866- Type :: NominalInstance ( instance) => match instance. class ( ) . known ( db) {
4863+ Type :: NominalInstance ( instance) => match instance. class . known ( db) {
48674864 Some ( KnownClass :: TypeVar ) => Ok ( todo_type ! (
48684865 "Support for `typing.TypeVar` instances in type expressions"
48694866 ) ) ,
@@ -5291,7 +5288,7 @@ impl<'db> Type<'db> {
52915288 }
52925289 Self :: GenericAlias ( alias) => Some ( TypeDefinition :: Class ( alias. definition ( db) ) ) ,
52935290 Self :: NominalInstance ( instance) => {
5294- Some ( TypeDefinition :: Class ( instance. class ( ) . definition ( db) ) )
5291+ Some ( TypeDefinition :: Class ( instance. class . definition ( db) ) )
52955292 }
52965293 Self :: KnownInstance ( instance) => match instance {
52975294 KnownInstanceType :: TypeVar ( var) => {
@@ -8046,7 +8043,7 @@ impl<'db> SuperOwnerKind<'db> {
80468043 Either :: Left ( ClassBase :: Dynamic ( dynamic) . mro ( db, None ) )
80478044 }
80488045 SuperOwnerKind :: Class ( class) => Either :: Right ( class. iter_mro ( db) ) ,
8049- SuperOwnerKind :: Instance ( instance) => Either :: Right ( instance. class ( ) . iter_mro ( db) ) ,
8046+ SuperOwnerKind :: Instance ( instance) => Either :: Right ( instance. class . iter_mro ( db) ) ,
80508047 }
80518048 }
80528049
@@ -8062,7 +8059,7 @@ impl<'db> SuperOwnerKind<'db> {
80628059 match self {
80638060 SuperOwnerKind :: Dynamic ( _) => None ,
80648061 SuperOwnerKind :: Class ( class) => Some ( class) ,
8065- SuperOwnerKind :: Instance ( instance) => Some ( instance. class ( ) ) ,
8062+ SuperOwnerKind :: Instance ( instance) => Some ( instance. class ) ,
80668063 }
80678064 }
80688065
@@ -8240,7 +8237,7 @@ impl<'db> BoundSuperType<'db> {
82408237 . expect ( "Calling `find_name_in_mro` on dynamic type should return `Some`" )
82418238 }
82428239 SuperOwnerKind :: Class ( class) => class,
8243- SuperOwnerKind :: Instance ( instance) => instance. class ( ) ,
8240+ SuperOwnerKind :: Instance ( instance) => instance. class ,
82448241 } ;
82458242
82468243 let ( class_literal, _) = class. class_literal ( db) ;
0 commit comments