mirror of
https://github.com/astral-sh/ruff.git
synced 2025-09-29 05:15:12 +00:00
[ty] Simplify Type::normalized
slightly (#18339)
This commit is contained in:
parent
9ec4a178a4
commit
e03e05d2b3
1 changed files with 1 additions and 25 deletions
|
@ -1026,34 +1026,10 @@ impl<'db> Type<'db> {
|
||||||
Type::BoundSuper(bound_super) => Type::BoundSuper(bound_super.normalized(db)),
|
Type::BoundSuper(bound_super) => Type::BoundSuper(bound_super.normalized(db)),
|
||||||
Type::GenericAlias(generic) => Type::GenericAlias(generic.normalized(db)),
|
Type::GenericAlias(generic) => Type::GenericAlias(generic.normalized(db)),
|
||||||
Type::SubclassOf(subclass_of) => Type::SubclassOf(subclass_of.normalized(db)),
|
Type::SubclassOf(subclass_of) => Type::SubclassOf(subclass_of.normalized(db)),
|
||||||
|
Type::TypeVar(typevar) => Type::TypeVar(typevar.normalized(db)),
|
||||||
Type::KnownInstance(known_instance) => {
|
Type::KnownInstance(known_instance) => {
|
||||||
Type::KnownInstance(known_instance.normalized(db))
|
Type::KnownInstance(known_instance.normalized(db))
|
||||||
}
|
}
|
||||||
Type::TypeVar(typevar) => match typevar.bound_or_constraints(db) {
|
|
||||||
Some(TypeVarBoundOrConstraints::UpperBound(bound)) => {
|
|
||||||
Type::TypeVar(TypeVarInstance::new(
|
|
||||||
db,
|
|
||||||
typevar.name(db).clone(),
|
|
||||||
typevar.definition(db),
|
|
||||||
Some(TypeVarBoundOrConstraints::UpperBound(bound.normalized(db))),
|
|
||||||
typevar.variance(db),
|
|
||||||
typevar.default_ty(db),
|
|
||||||
typevar.kind(db),
|
|
||||||
))
|
|
||||||
}
|
|
||||||
Some(TypeVarBoundOrConstraints::Constraints(union)) => {
|
|
||||||
Type::TypeVar(TypeVarInstance::new(
|
|
||||||
db,
|
|
||||||
typevar.name(db).clone(),
|
|
||||||
typevar.definition(db),
|
|
||||||
Some(TypeVarBoundOrConstraints::Constraints(union.normalized(db))),
|
|
||||||
typevar.variance(db),
|
|
||||||
typevar.default_ty(db),
|
|
||||||
typevar.kind(db),
|
|
||||||
))
|
|
||||||
}
|
|
||||||
None => self,
|
|
||||||
},
|
|
||||||
Type::LiteralString
|
Type::LiteralString
|
||||||
| Type::AlwaysFalsy
|
| Type::AlwaysFalsy
|
||||||
| Type::AlwaysTruthy
|
| Type::AlwaysTruthy
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue