Skip to content

Commit 7fd5d53

Browse files
committed
Minor adjustments
1 parent 7408664 commit 7fd5d53

File tree

2 files changed

+14
-18
lines changed

2 files changed

+14
-18
lines changed

crates/ty_python_semantic/src/types.rs

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6008,7 +6008,7 @@ impl<'db> Type<'db> {
60086008
TypeMapping::PromoteLiterals |
60096009
TypeMapping::BindLegacyTypevars(_) |
60106010
TypeMapping::BindSelf(_) |
6011-
TypeMapping::ReplaceSelf { new_upper_bound: _ }
6011+
TypeMapping::ReplaceSelf { .. }
60126012
=> self,
60136013
TypeMapping::Materialize(materialization_kind) => Type::NonInferableTypeVar(bound_typevar.materialize_impl(db, *materialization_kind, visitor))
60146014

@@ -6022,7 +6022,7 @@ impl<'db> Type<'db> {
60226022
TypeMapping::PartialSpecialization(_) |
60236023
TypeMapping::PromoteLiterals |
60246024
TypeMapping::BindSelf(_) |
6025-
TypeMapping::ReplaceSelf { new_upper_bound: _ } |
6025+
TypeMapping::ReplaceSelf { .. } |
60266026
TypeMapping::MarkTypeVarsInferable(_) |
60276027
TypeMapping::Materialize(_) => self,
60286028
}
@@ -6131,7 +6131,7 @@ impl<'db> Type<'db> {
61316131
TypeMapping::PartialSpecialization(_) |
61326132
TypeMapping::BindLegacyTypevars(_) |
61336133
TypeMapping::BindSelf(_) |
6134-
TypeMapping::ReplaceSelf { new_upper_bound: _ } |
6134+
TypeMapping::ReplaceSelf { .. } |
61356135
TypeMapping::MarkTypeVarsInferable(_) |
61366136
TypeMapping::Materialize(_) => self,
61376137
TypeMapping::PromoteLiterals => self.literal_fallback_instance(db)
@@ -6143,7 +6143,7 @@ impl<'db> Type<'db> {
61436143
TypeMapping::PartialSpecialization(_) |
61446144
TypeMapping::BindLegacyTypevars(_) |
61456145
TypeMapping::BindSelf(_) |
6146-
TypeMapping::ReplaceSelf { new_upper_bound: _ } |
6146+
TypeMapping::ReplaceSelf { .. } |
61476147
TypeMapping::MarkTypeVarsInferable(_) |
61486148
TypeMapping::PromoteLiterals => self,
61496149
TypeMapping::Materialize(materialization_kind) => match materialization_kind {
@@ -6679,7 +6679,7 @@ pub enum TypeMapping<'a, 'db> {
66796679
BindLegacyTypevars(BindingContext<'db>),
66806680
/// Binds any `typing.Self` typevar with a particular `self` class.
66816681
BindSelf(Type<'db>),
6682-
/// Replaces occurrences of `typing.Self` with a new `Self` type variable that has the given upper bound.
6682+
/// Replaces occurrences of `typing.Self` with a new `Self` type variable with the given upper bound.
66836683
ReplaceSelf { new_upper_bound: Type<'db> },
66846684
/// Marks the typevars that are bound by a generic class or function as inferable.
66856685
MarkTypeVarsInferable(BindingContext<'db>),
@@ -6726,10 +6726,8 @@ impl<'db> TypeMapping<'_, 'db> {
67266726
TypeMapping::BindLegacyTypevars(*binding_context)
67276727
}
67286728
TypeMapping::BindSelf(self_type) => TypeMapping::BindSelf(*self_type),
6729-
TypeMapping::ReplaceSelf {
6730-
new_upper_bound: replacement_type,
6731-
} => TypeMapping::ReplaceSelf {
6732-
new_upper_bound: *replacement_type,
6729+
TypeMapping::ReplaceSelf { new_upper_bound } => TypeMapping::ReplaceSelf {
6730+
new_upper_bound: *new_upper_bound,
67336731
},
67346732
TypeMapping::MarkTypeVarsInferable(binding_context) => {
67356733
TypeMapping::MarkTypeVarsInferable(*binding_context)
@@ -6755,10 +6753,8 @@ impl<'db> TypeMapping<'_, 'db> {
67556753
TypeMapping::BindSelf(self_type) => {
67566754
TypeMapping::BindSelf(self_type.normalized_impl(db, visitor))
67576755
}
6758-
TypeMapping::ReplaceSelf {
6759-
new_upper_bound: replacement_type,
6760-
} => TypeMapping::ReplaceSelf {
6761-
new_upper_bound: replacement_type.normalized_impl(db, visitor),
6756+
TypeMapping::ReplaceSelf { new_upper_bound } => TypeMapping::ReplaceSelf {
6757+
new_upper_bound: new_upper_bound.normalized_impl(db, visitor),
67626758
},
67636759
TypeMapping::MarkTypeVarsInferable(binding_context) => {
67646760
TypeMapping::MarkTypeVarsInferable(*binding_context)
@@ -10923,7 +10919,7 @@ impl<'db> TypeIsType<'db> {
1092310919
/// Walk the MRO of this class and return the last class just before the specified known base.
1092410920
/// This can be used to determine upper bounds for `Self` type variables on methods that are
1092510921
/// being added to the given class.
10926-
pub(super) fn find_upper_bound<'db>(
10922+
pub(super) fn determine_upper_bound<'db>(
1092710923
db: &'db dyn Db,
1092810924
class_literal: ClassLiteral<'db>,
1092910925
specialization: Option<Specialization<'db>>,

crates/ty_python_semantic/src/types/class.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ use crate::types::{
3030
IsEquivalentVisitor, KnownInstanceType, ManualPEP695TypeAliasType, MaterializationKind,
3131
NormalizedVisitor, PropertyInstanceType, StringLiteralType, TypeAliasType, TypeContext,
3232
TypeMapping, TypeRelation, TypeVarBoundOrConstraints, TypeVarInstance, TypeVarKind,
33-
TypedDictParams, UnionBuilder, VarianceInferable, declaration_type, find_upper_bound,
33+
TypedDictParams, UnionBuilder, VarianceInferable, declaration_type, determine_upper_bound,
3434
infer_definition_types,
3535
};
3636
use crate::{
@@ -1985,7 +1985,7 @@ impl<'db> ClassLiteral<'db> {
19851985
ty.apply_type_mapping(
19861986
db,
19871987
&TypeMapping::ReplaceSelf {
1988-
new_upper_bound: find_upper_bound(
1988+
new_upper_bound: determine_upper_bound(
19891989
db,
19901990
self,
19911991
None,
@@ -2278,7 +2278,7 @@ impl<'db> ClassLiteral<'db> {
22782278
ty.apply_type_mapping(
22792279
db,
22802280
&TypeMapping::ReplaceSelf {
2281-
new_upper_bound: find_upper_bound(
2281+
new_upper_bound: determine_upper_bound(
22822282
db,
22832283
self,
22842284
specialization,
@@ -2615,7 +2615,7 @@ impl<'db> ClassLiteral<'db> {
26152615
.map_type(|ty|
26162616
ty.apply_type_mapping(
26172617
db,
2618-
&TypeMapping::ReplaceSelf {new_upper_bound: find_upper_bound(db, self, specialization, ClassBase::is_typed_dict) }
2618+
&TypeMapping::ReplaceSelf {new_upper_bound: determine_upper_bound(db, self, specialization, ClassBase::is_typed_dict) }
26192619
)
26202620
)
26212621
}

0 commit comments

Comments
 (0)