From eb60bd64fd5ed23111d3672681ac73e84699878d Mon Sep 17 00:00:00 2001 From: Carl Meyer Date: Tue, 10 Jun 2025 13:22:25 -0700 Subject: [PATCH] [ty] more simplification of infer_parameterized_legacy_typing_alias (#18526) Address post-land review on https://github.com/astral-sh/ruff/pull/18489 --- crates/ty_python_semantic/src/types/infer.rs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/crates/ty_python_semantic/src/types/infer.rs b/crates/ty_python_semantic/src/types/infer.rs index ea20cace2c..5c99354bb6 100644 --- a/crates/ty_python_semantic/src/types/infer.rs +++ b/crates/ty_python_semantic/src/types/infer.rs @@ -9108,12 +9108,12 @@ impl<'db> TypeInferenceBuilder<'db, '_> { class: KnownClass, ) -> Type<'db> { let arguments = &*subscript_node.slice; - let (args, args_number) = if let ast::Expr::Tuple(t) = arguments { - (t.iter(), t.len()) + let args = if let ast::Expr::Tuple(t) = arguments { + &*t.elts } else { - (std::slice::from_ref(arguments).iter(), 1) + std::slice::from_ref(arguments) }; - if args_number != expected_arg_count { + if args.len() != expected_arg_count { if let Some(builder) = self.context.report_lint(&INVALID_TYPE_FORM, subscript_node) { let noun = if expected_arg_count == 1 { "argument" @@ -9122,14 +9122,14 @@ impl<'db> TypeInferenceBuilder<'db, '_> { }; builder.into_diagnostic(format_args!( "Legacy alias `{alias}` expected exactly {expected_arg_count} {noun}, \ - got {args_number}", + got {}", + args.len() )); } } let ty = class.to_specialized_instance( self.db(), - args.into_iter() - .map(|node| self.infer_type_expression(node)), + args.iter().map(|node| self.infer_type_expression(node)), ); if arguments.is_tuple_expr() { self.store_expression_type(arguments, ty);