From 2a6dde4acb6cb6a8ef4426ca3d792bdb1c477f21 Mon Sep 17 00:00:00 2001 From: David Peter Date: Mon, 15 Sep 2025 17:40:10 +0200 Subject: [PATCH] [ty] Remove `Self` from generic context when binding `Self` (#20364) ## Summary This mainly removes an internal inconsistency, where we didn't remove the `Self` type variable when eagerly binding `Self` to an instance type. It has no observable effect, apparently. builds on top of https://github.com/astral-sh/ruff/pull/20328 ## Test Plan None --- crates/ty_python_semantic/src/types.rs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/crates/ty_python_semantic/src/types.rs b/crates/ty_python_semantic/src/types.rs index d31cc6115c..7c6028739e 100644 --- a/crates/ty_python_semantic/src/types.rs +++ b/crates/ty_python_semantic/src/types.rs @@ -6777,8 +6777,15 @@ impl<'db> TypeMapping<'_, 'db> { | TypeMapping::PromoteLiterals | TypeMapping::BindLegacyTypevars(_) | TypeMapping::MarkTypeVarsInferable(_) - | TypeMapping::Materialize(_) - | TypeMapping::BindSelf(_) => context, + | TypeMapping::Materialize(_) => context, + TypeMapping::BindSelf(_) => GenericContext::from_typevar_instances( + db, + context + .variables(db) + .iter() + .filter(|var| !var.typevar(db).is_self(db)) + .copied(), + ), TypeMapping::ReplaceSelf { new_upper_bound } => GenericContext::from_typevar_instances( db, context.variables(db).iter().map(|typevar| {