diff --git a/crates/ruff/src/rules/flake8_gettext/settings.rs b/crates/ruff/src/rules/flake8_gettext/settings.rs index 6146f6f934..58058fc692 100644 --- a/crates/ruff/src/rules/flake8_gettext/settings.rs +++ b/crates/ruff/src/rules/flake8_gettext/settings.rs @@ -22,10 +22,9 @@ pub struct Options { value_type = "list[str]", example = r#"extend-function-names = ["ugettetxt"]"# )] - #[serde(default)] /// Additional function names to consider as internationalization calls, in addition to those /// included in `function-names`. - pub extend_function_names: Vec, + pub extend_function_names: Option>, } #[derive(Debug, CacheKey)] @@ -34,10 +33,11 @@ pub struct Settings { } fn default_func_names() -> Vec { - ["_", "gettext", "ngettext"] - .iter() - .map(std::string::ToString::to_string) - .collect() + vec![ + "_".to_string(), + "gettext".to_string(), + "ngettext".to_string(), + ] } impl Default for Settings { @@ -55,7 +55,12 @@ impl From for Settings { .function_names .unwrap_or_else(default_func_names) .into_iter() - .chain(options.extend_function_names) + .chain( + options + .extend_function_names + .unwrap_or_default() + .into_iter(), + ) .collect(), } } @@ -65,7 +70,7 @@ impl From for Options { fn from(settings: Settings) -> Self { Self { function_names: Some(settings.functions_names), - extend_function_names: vec![], + extend_function_names: Some(Vec::new()), } } } diff --git a/ruff.schema.json b/ruff.schema.json index adf5566311..dafa42567c 100644 --- a/ruff.schema.json +++ b/ruff.schema.json @@ -712,8 +712,10 @@ "properties": { "extend-function-names": { "description": "Additional function names to consider as internationalization calls, in addition to those included in `function-names`.", - "default": [], - "type": "array", + "type": [ + "array", + "null" + ], "items": { "type": "string" }