Repository: astral-sh/ruff
File: crates/ty_python_semantic/src/types/call/bind.rs (Rust)

Code before:
            // `*args: P.args` (another ParamSpec).
            Some(argument_type) => match argument_type.as_paramspec_typevar(db) {
                Some(paramspec) => VariadicArgumentType::ParamSpec(paramspec),
                None => match argument_type {
                    // `Type::iterate` unions tuple specs in a way that can invent additional
                    // arities. For signatures where all remaining positional parameters are
                    // defaulted, map each possible tuple index from the union to the
                    // corresponding optional positional parameter.
                    Type::Union(union)
                        if self.parameters.variadic().is_none()
                            && self
                                .parameters
                                .positional()
                                .skip(self.next_positional)
                                .all(|parameter| parameter.default_type().is_some()) =>
                    {
                        let tuple_specs = union
                            .elements(db)
                            .iter()
                            .map(|ty| {
                                ty.try_iterate(db).unwrap_or_else(|err| {
                                    Cow::Owned(TupleSpec::homogeneous(
                                        err.fallback_element_type(db),
                                    ))
                                })
                            })
                            .collect_vec();

                        let any_variable_length =
                            tuple_specs.iter().any(|spec| spec.len().is_variable());
                        let mut tuple_index = 0usize;

                        while self
                            .parameters
                            .get_positional(self.next_positional)
                            .is_some()
                        {
                            if any_variable_length
                                && self
                                    .explicit_keyword_parameters
                                    .contains(&self.next_positional)
                            {
                                break;
                            }

                            let Ok(tuple_index_i32) = i32::try_from(tuple_index) else {
                                break;
                            };

                            let positional_types = tuple_specs
                                .iter()

Review comment (suggestion):
```suggestion
                            .map(|ty| ty.iterate(db))
```

Code after:
                // [1]: https://github.com/astral-sh/ty/issues/274#issuecomment-2881856028
                let function_type_and_kind = match self.signature_type {
                    Type::FunctionLiteral(function) => Some((FunctionKind::Function, function)),
                    Type::BoundMethod(bound_method) => Some((
                        FunctionKind::BoundMethod,
                        bound_method.function(context.db()),
                    )),
                    Type::KnownBoundMethod(KnownBoundMethodType::FunctionTypeDunderGet(
                        function,
                    )) => Some((FunctionKind::MethodWrapper, function)),
                    _ => None,
                };

                // If only one overload passed arity check, report its errors directly.
                if let Some(matching_overload_index) = self.matching_overload_before_type_checking {
                    let callable_description =
                        CallableDescription::new(context.db(), self.signature_type);
                    let matching_overload =
                        function_type_and_kind.map(|(kind, function)| MatchingOverloadLiteral {
                            index: matching_overload_index,
                            kind,
                            function,
                        });
                    self.overloads[matching_overload_index].report_diagnostics(
                        context,
                        node,
                        self.signature_type,
                        callable_description.as_ref(),
                        compound_diag,
                        matching_overload.as_ref(),
                    );
                    return;
                }

                // If multiple overloads passed arity check but only one matched types
                // (possibly with semantic errors), report its errors directly instead
                // of the generic "no matching overload" message.
                if let MatchingOverloadIndex::Single(matching_overload_index) =
                    self.matching_overload_index()
                {
                    let callable_description =
                        CallableDescription::new(context.db(), self.signature_type);
                    let matching_overload =
                        function_type_and_kind.map(|(kind, function)| MatchingOverloadLiteral {
                            index: matching_overload_index,
                            kind,
                            function,
                        });
                    self.overloads[matching_overload_index].report_diagnostics(
                        context,
                        node,