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

Code before:
                                KnownClass::Iterator.to_specialized_instance(db, [enum_instance]),
                            );
                        }
                    }

                    function @ Type::FunctionLiteral(function_type)
                        if dataclass_field_specifiers.contains(&function)
                            || function_type.is_known(db, KnownFunction::Field) =>
                    {
                        // Helper to get the type of a keyword argument by name. We first try to get it from
                        // the parameter binding (for explicit parameters), and then fall back to checking the
                        // call site arguments (for field-specifier functions that use a `**kwargs` parameter,
                        // instead of specifying `init`, `default` etc. explicitly).
                        let get_argument_type =
                            |name: &str, fallback_to_default: bool| -> Option<Type<'db>> {
                                if let Ok(ty) =
                                    overload.parameter_type_by_name(name, fallback_to_default)
                                {
                                    return ty;
                                }
                                argument_types.iter().find_map(|(arg, ty)| {
                                if matches!(arg, Argument::Keyword(arg_name) if arg_name == name) {
                                    ty
                                } else {
                                    None
                                }
                            })
                            };

                        let has_default_value = get_argument_type("default", false).is_some()
                            || get_argument_type("default_factory", false).is_some()
                            || get_argument_type("factory", false).is_some();

                        let init = get_argument_type("init", true);
                        let kw_only = get_argument_type("kw_only", true);
                        let alias = get_argument_type("alias", true);

                        // `dataclasses.field` and field-specifier functions of commonly used
                        // libraries like `pydantic`, `attrs`, and `SQLAlchemy` all return
                        // the default type for the field (or `Any`) instead of an actual `Field`
                        // instance, even if this is not what happens at runtime (see also below).
                        // We still make use of this fact and pretend that all field specifiers
                        // return the type of the default value:
                        let default_ty = if has_default_value {
                            Some(overload.return_ty)
                        } else {
                            None
                        };

                        let init = init
                            .map(|init| !init.bool(db).is_always_false())

Review comment (suggestion):
nit: the formatting looks a bit off here

```suggestion
	                                if matches!(arg, Argument::Keyword(arg_name) if arg_name == name) {
	                                    ty
	                                } else {
	                                    None
	                                }
	                            })
	```

Code after:
                                KnownClass::Iterator.to_specialized_instance(db, [enum_instance]),
                            );
                        }
                    }

                    function @ Type::FunctionLiteral(function_type)
                        if dataclass_field_specifiers.contains(&function)
                            || function_type.is_known(db, KnownFunction::Field) =>
                    {
                        // Helper to get the type of a keyword argument by name. We first try to get it from
                        // the parameter binding (for explicit parameters), and then fall back to checking the
                        // call site arguments (for field-specifier functions that use a `**kwargs` parameter,
                        // instead of specifying `init`, `default` etc. explicitly).
                        let get_argument_type = |name, fallback_to_default| -> Option<Type<'db>> {
                            if let Ok(ty) =
                                overload.parameter_type_by_name(name, fallback_to_default)
                            {
                                return ty;
                            }
                            argument_types.iter().find_map(|(arg, ty)| {
                                if matches!(arg, Argument::Keyword(arg_name) if arg_name == name) {
                                    ty
                                } else {
                                    None
                                }
                            })
                        };

                        let has_default_value = get_argument_type("default", false).is_some()
                            || get_argument_type("default_factory", false).is_some()
                            || get_argument_type("factory", false).is_some();

                        let init = get_argument_type("init", true);
                        let kw_only = get_argument_type("kw_only", true);
                        let alias = get_argument_type("alias", true);

                        // `dataclasses.field` and field-specifier functions of commonly used
                        // libraries like `pydantic`, `attrs`, and `SQLAlchemy` all return
                        // the default type for the field (or `Any`) instead of an actual `Field`
                        // instance, even if this is not what happens at runtime (see also below).
                        // We still make use of this fact and pretend that all field specifiers
                        // return the type of the default value:
                        let default_ty = if has_default_value {
                            Some(overload.return_ty)
                        } else {
                            None
                        };

                        let init = init
                            .map(|init| !init.bool(db).is_always_false())
                            .unwrap_or(true);