mirror of
https://github.com/astral-sh/ruff.git
synced 2025-09-30 22:01:18 +00:00
[ty] allow T: Never
as subtype of Never
(#18687)
This commit is contained in:
parent
5e57e4680f
commit
373a3bfcd6
3 changed files with 10 additions and 6 deletions
|
@ -1204,9 +1204,7 @@ impl<'db> Type<'db> {
|
|||
|
||||
// `Never` is the bottom type, the empty set.
|
||||
// It is a subtype of all other fully static types.
|
||||
// No other fully static type is a subtype of `Never`.
|
||||
(Type::Never, _) => true,
|
||||
(_, Type::Never) => false,
|
||||
|
||||
// Everything is a subtype of `object`.
|
||||
(_, Type::NominalInstance(instance)) if instance.class.is_object(db) => true,
|
||||
|
@ -1260,6 +1258,11 @@ impl<'db> Type<'db> {
|
|||
true
|
||||
}
|
||||
|
||||
// `Never` is the bottom type, the empty set.
|
||||
// Other than one unlikely edge case (TypeVars bound to `Never`),
|
||||
// no other fully static type is a subtype of `Never`.
|
||||
(_, Type::Never) => false,
|
||||
|
||||
(Type::Union(union), _) => union
|
||||
.elements(db)
|
||||
.iter()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue