diff --git a/crates/ty_python_semantic/src/types/class.rs b/crates/ty_python_semantic/src/types/class.rs index d2a5a1871f..e7be2637d7 100644 --- a/crates/ty_python_semantic/src/types/class.rs +++ b/crates/ty_python_semantic/src/types/class.rs @@ -1215,7 +1215,11 @@ impl<'db> ClassType<'db> { let self_annotation = signature .parameters() .get_positional(0) - .and_then(Parameter::annotated_type); + .and_then(Parameter::annotated_type) + .filter(|ty| { + ty.as_typevar() + .is_none_or(|bound_typevar| !bound_typevar.typevar(db).is_self(db)) + }); let return_type = self_annotation.unwrap_or(correct_return_type); let instance_ty = self_annotation.unwrap_or_else(|| Type::instance(db, self)); Signature::new(signature.parameters().clone(), Some(return_type))