mirror of
https://github.com/astral-sh/ruff.git
synced 2025-11-18 11:41:21 +00:00
normalize for consistent output
This commit is contained in:
parent
b3f85fee30
commit
a28f562fa7
3 changed files with 8 additions and 2 deletions
|
|
@ -43,7 +43,7 @@ def unbounded[T]():
|
|||
reveal_type(generic_context(unbounded).specialize_constrained(ConstraintSet.range(Never, T, int) | ConstraintSet.range(Never, T, bool)))
|
||||
# revealed: ty_extensions.Specialization[T@unbounded = int | str]
|
||||
reveal_type(generic_context(unbounded).specialize_constrained(ConstraintSet.range(Never, T, int) | ConstraintSet.range(Never, T, str)))
|
||||
# revealed: ty_extensions.Specialization[T@unbounded = str | bool]
|
||||
# revealed: ty_extensions.Specialization[T@unbounded = bool | str]
|
||||
reveal_type(generic_context(unbounded).specialize_constrained(ConstraintSet.range(bool, T, bool) | ConstraintSet.range(Never, T, str)))
|
||||
```
|
||||
|
||||
|
|
|
|||
|
|
@ -8217,10 +8217,11 @@ impl<'db> KnownInstanceType<'db> {
|
|||
)
|
||||
}
|
||||
KnownInstanceType::Specialization(specialization) => {
|
||||
// Normalize for consistent output across CI platforms
|
||||
write!(
|
||||
f,
|
||||
"ty_extensions.Specialization{}",
|
||||
specialization.display_full(self.db)
|
||||
specialization.normalized(self.db).display_full(self.db)
|
||||
)
|
||||
}
|
||||
KnownInstanceType::UnionType(_) => f.write_str("types.UnionType"),
|
||||
|
|
|
|||
|
|
@ -1003,6 +1003,11 @@ impl<'db> Specialization<'db> {
|
|||
Specialization::new(db, self.generic_context(db), types, None, None)
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
pub(crate) fn normalized(self, db: &'db dyn Db) -> Self {
|
||||
self.normalized_impl(db, &NormalizedVisitor::default())
|
||||
}
|
||||
|
||||
pub(crate) fn normalized_impl(self, db: &'db dyn Db, visitor: &NormalizedVisitor<'db>) -> Self {
|
||||
let types: Box<[_]> = self
|
||||
.types(db)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue