mirror of
https://github.com/astral-sh/ruff.git
synced 2025-09-28 04:45:01 +00:00
[ty]: Consider a class with a dynamic element in its MRO assignable to any subtype of type
(#18205)
This commit is contained in:
parent
4fad15805b
commit
fb589730ef
4 changed files with 54 additions and 0 deletions
|
@ -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
|
||||
|
|
|
@ -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> {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue