Skip to content

Commit

Permalink
Remove NoneType <: NoneType special case
Browse files Browse the repository at this point in the history
  • Loading branch information
sharkdp committed Oct 31, 2024
1 parent 1735975 commit 0ff025a
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions crates/red_knot_python_semantic/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 0ff025a

Please sign in to comment.