ruff
42bbb782 - [ty] Add deterministic ordering for union/intersection type elements

Commit
98 days ago
[ty] Add deterministic ordering for union/intersection type elements Add `OrderingPurpose` enum to distinguish between two use cases for type ordering: - `Normalization`: Fast ordering using Salsa IDs for building canonical unions/intersections (existing behavior) - `Determinism`: Structural ordering using stable data (file paths, names, definitions) that produces the same results across different runs of ty The deterministic ordering compares types by their structural properties rather than Salsa-assigned IDs, which can change between runs due to garbage collection and recreation of interned types. Key changes: - Add `OrderingPurpose` parameter to `union_or_intersection_elements_ordering` - Implement deterministic ordering for `FunctionLiteral`, `BoundMethod`, `KnownBoundMethod`, `DataclassDecorator`, `DataclassTransformer`, `Callable`, `KnownInstance`, `TypeVar`, `TypeAlias`, `TypedDict`, `NewTypeInstance`, `PropertyInstance`, `ProtocolInstance` (synthesized), `NominalInstance`, `BoundSuper`, and literal value types - Add `definition_ordering` helper for stable comparison via file paths - Add `ProtocolMember::ordering` method for structural protocol comparison - Add `Ord`/`PartialOrd` derives to `ScopedSymbolId`, `ScopedMemberId`, `ScopedPlaceId`, `FileScopeId`, `TypeQualifiers`, `TypeVarKind`, `RecursivelyDefined` to support structural comparisons - Remove `Ord`/`PartialOrd` from `ProtocolInstanceType` (ordering now handled structurally in `type_ordering.rs`) - Add ordering doc comments to types with non-obvious ordering semantics https://claude.ai/code/session_01VfHXjU3ua6PKgWBHisG7TJ
Author
Committer
Parents
Loading