diff --git a/README.md b/README.md index f39b83826b..4a0a475616 100644 --- a/README.md +++ b/README.md @@ -3120,7 +3120,7 @@ and can be circumvented via `eval` or `importlib`. Exempt certain modules from needing to be moved into type-checking blocks. -**Default value**: `[]` +**Default value**: `["typing"]` **Type**: `Vec` @@ -3128,7 +3128,7 @@ blocks. ```toml [tool.ruff.flake8-type-checking] -exempt-modules = ["typing_extensions"] +exempt-modules = ["typing", "typing_extensions"] ``` --- diff --git a/src/rules/flake8_type_checking/settings.rs b/src/rules/flake8_type_checking/settings.rs index 4512cadfe1..6e4269f5d1 100644 --- a/src/rules/flake8_type_checking/settings.rs +++ b/src/rules/flake8_type_checking/settings.rs @@ -25,10 +25,10 @@ pub struct Options { /// See: https://github.com/snok/flake8-type-checking#strict. pub strict: Option, #[option( - default = "[]", + default = "[\"typing\"]", value_type = "Vec", example = r#" - exempt-modules = ["typing_extensions"] + exempt-modules = ["typing", "typing_extensions"] "# )] /// Exempt certain modules from needing to be moved into type-checking @@ -36,17 +36,28 @@ pub struct Options { pub exempt_modules: Option>, } -#[derive(Debug, Hash, Default)] +#[derive(Debug, Hash)] pub struct Settings { pub strict: bool, pub exempt_modules: Vec, } +impl Default for Settings { + fn default() -> Self { + Self { + strict: false, + exempt_modules: vec!["typing".to_string()], + } + } +} + impl From for Settings { fn from(options: Options) -> Self { Self { - strict: options.strict.unwrap_or_default(), - exempt_modules: options.exempt_modules.unwrap_or_default(), + strict: options.strict.unwrap_or(false), + exempt_modules: options + .exempt_modules + .unwrap_or_else(|| vec!["typing".to_string()]), } } }