diff --git a/crates/ty_python_semantic/resources/mdtest/attributes.md b/crates/ty_python_semantic/resources/mdtest/attributes.md index 5d62823853..1c708bbb65 100644 --- a/crates/ty_python_semantic/resources/mdtest/attributes.md +++ b/crates/ty_python_semantic/resources/mdtest/attributes.md @@ -2382,7 +2382,7 @@ class B: self.x = other.x reveal_type(B().x) # revealed: Literal[1] | Unknown -reveal_type(A().x) # revealed: Unknown | Literal[1] +reveal_type(A().x) # revealed: Literal[1] | Unknown class Base: def flip(self) -> "Sub": @@ -2674,7 +2674,7 @@ class C: self.x = (other.x, 1) reveal_type(C().x) # revealed: tuple[Divergent, Literal[1]] | Unknown -reveal_type(C().x[0]) # revealed: Divergent | Unknown +reveal_type(C().x[0]) # revealed: Unknown | Divergent ``` This also works if the tuple is not constructed directly: diff --git a/crates/ty_python_semantic/resources/mdtest/cycle.md b/crates/ty_python_semantic/resources/mdtest/cycle.md index 6878c803c0..a1af27e3c9 100644 --- a/crates/ty_python_semantic/resources/mdtest/cycle.md +++ b/crates/ty_python_semantic/resources/mdtest/cycle.md @@ -29,7 +29,7 @@ class Point: p = Point() reveal_type(p.x) # revealed: int | Unknown -reveal_type(p.y) # revealed: Unknown | int +reveal_type(p.y) # revealed: int | Unknown ``` ## Self-referential bare type alias diff --git a/crates/ty_python_semantic/resources/mdtest/generics/pep695/aliases.md b/crates/ty_python_semantic/resources/mdtest/generics/pep695/aliases.md index a8c69f1f7f..57fc838498 100644 --- a/crates/ty_python_semantic/resources/mdtest/generics/pep695/aliases.md +++ b/crates/ty_python_semantic/resources/mdtest/generics/pep695/aliases.md @@ -189,7 +189,7 @@ r5: RecursiveList[int] = [1, ["a"]] def _(x: RecursiveList[int]): if isinstance(x, list): # TODO: should be `list[RecursiveList[int]] - reveal_type(x[0]) # revealed: list[Any] | int + reveal_type(x[0]) # revealed: int | list[Any] if isinstance(x, list) and isinstance(x[0], list): # TODO: should be `list[RecursiveList[int]]` reveal_type(x[0]) # revealed: list[Any] diff --git a/crates/ty_python_semantic/src/types/builder.rs b/crates/ty_python_semantic/src/types/builder.rs index a9936023df..2240a2aa28 100644 --- a/crates/ty_python_semantic/src/types/builder.rs +++ b/crates/ty_python_semantic/src/types/builder.rs @@ -593,7 +593,7 @@ impl<'db> UnionBuilder<'db> { // If the type is defined recursively, the union type is sorted and normalized. // This is because the execution order of the queries is not deterministic and may result in a different order of elements. // The order of the union type does not affect the type check result, but unstable output is undesirable. - if self.cycle_recovery && self.recursively_defined.is_yes() { + if self.recursively_defined.is_yes() { self.order_elements = true; } let mut types = vec![]; @@ -613,7 +613,7 @@ impl<'db> UnionBuilder<'db> { } if self.order_elements { types.sort_unstable_by(|l, r| { - if self.cycle_recovery && self.recursively_defined.is_yes() { + if self.recursively_defined.is_yes() { structural_type_ordering(self.db, l, r) } else { union_or_intersection_elements_ordering(self.db, l, r)