[ty]: Consider a class with a dynamic element in its MRO assignable to any subtype of type (#18205)

This commit is contained in:
Felix Scherz 2025-05-19 21:30:30 +02:00 committed by GitHub
parent 4fad15805b
commit fb589730ef
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 54 additions and 0 deletions

View file

@ -1542,6 +1542,14 @@ impl<'db> Type<'db> {
true
}
(Type::ClassLiteral(class), Type::SubclassOf(_))
if class
.iter_mro(db, None)
.any(class_base::ClassBase::is_dynamic) =>
{
true
}
// Every `type[...]` is assignable to `type`
(Type::SubclassOf(_), _)
if KnownClass::Type

View file

@ -303,6 +303,10 @@ impl<'db> ClassBase<'db> {
}
}
}
pub(crate) const fn is_dynamic(self) -> bool {
matches!(self, Self::Dynamic(_))
}
}
impl<'db> From<ClassType<'db>> for ClassBase<'db> {