mirror of https://github.com/astral-sh/ruff
Revert "experiment: sort unions in cycle recovery functions"
This reverts commit 74d3ad6ef4.
This commit is contained in:
parent
74d3ad6ef4
commit
5964d7d9d6
|
|
@ -14194,7 +14194,7 @@ impl<'db> UnionType<'db> {
|
||||||
nested: bool,
|
nested: bool,
|
||||||
) -> Option<Type<'db>> {
|
) -> Option<Type<'db>> {
|
||||||
let mut builder = UnionBuilder::new(db)
|
let mut builder = UnionBuilder::new(db)
|
||||||
.order_elements(true)
|
.order_elements(false)
|
||||||
.unpack_aliases(false)
|
.unpack_aliases(false)
|
||||||
.cycle_recovery(true)
|
.cycle_recovery(true)
|
||||||
.recursively_defined(self.recursively_defined(db));
|
.recursively_defined(self.recursively_defined(db));
|
||||||
|
|
|
||||||
|
|
@ -38,6 +38,7 @@
|
||||||
//! unnecessary `is_subtype_of` checks.
|
//! unnecessary `is_subtype_of` checks.
|
||||||
|
|
||||||
use crate::types::enums::{enum_member_literals, enum_metadata};
|
use crate::types::enums::{enum_member_literals, enum_metadata};
|
||||||
|
use crate::types::type_ordering::union_or_intersection_elements_ordering;
|
||||||
use crate::types::{
|
use crate::types::{
|
||||||
BytesLiteralType, IntersectionType, KnownClass, StringLiteralType, Type,
|
BytesLiteralType, IntersectionType, KnownClass, StringLiteralType, Type,
|
||||||
TypeVarBoundOrConstraints, UnionType, structural_type_ordering,
|
TypeVarBoundOrConstraints, UnionType, structural_type_ordering,
|
||||||
|
|
@ -651,7 +652,13 @@ impl<'db> UnionBuilder<'db> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if self.order_elements {
|
if self.order_elements {
|
||||||
types.sort_unstable_by(|l, r| structural_type_ordering(self.db, l, r));
|
types.sort_unstable_by(|l, r| {
|
||||||
|
if self.recursively_defined.is_yes() {
|
||||||
|
structural_type_ordering(self.db, l, r)
|
||||||
|
} else {
|
||||||
|
union_or_intersection_elements_ordering(self.db, l, r)
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
match types.len() {
|
match types.len() {
|
||||||
0 => None,
|
0 => None,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue