diff --git a/crates/red_knot_python_semantic/src/types.rs b/crates/red_knot_python_semantic/src/types.rs index 89623d383a47c9..a5bb0df88b90b3 100644 --- a/crates/red_knot_python_semantic/src/types.rs +++ b/crates/red_knot_python_semantic/src/types.rs @@ -523,11 +523,6 @@ impl<'db> Type<'db> { .elements(db) .iter() .any(|&elem_ty| ty.is_subtype_of(db, elem_ty)), - (Type::Instance(self_class), Type::Instance(target_class)) - if self_class.is_known(db, KnownClass::NoneType) => - { - target_class.is_known(db, KnownClass::NoneType) - } (Type::Instance(self_class), Type::Instance(target_class)) => { self_class.is_subclass_of(db, target_class) } @@ -1848,7 +1843,10 @@ impl<'db> ClassType<'db> { pub fn is_subclass_of(self, db: &'db dyn Db, other: ClassType) -> bool { // TODO: we need to iterate over the *MRO* here, not the bases + // Note: the other == self check tests for equality of salsa IDs, but not for + // actual equality of the classes. (other == self) + || (self.known(db) == other.known(db)) || self.bases(db).any(|base| match base { Type::ClassLiteral(base_class) => base_class == other, // `is_subclass_of` is checking the subtype relation, in which gradual types do not