From 4a8b65b42984a77ea2ec8d3aa500bb04dc351508 Mon Sep 17 00:00:00 2001 From: Charlie Marsh Date: Sun, 5 Mar 2023 18:21:34 -0500 Subject: [PATCH] Remove pydantic.BaseModel from defaults --- crates/ruff/src/rules/flake8_type_checking/mod.rs | 1 + .../src/rules/flake8_type_checking/settings.rs | 14 +++++++------- ruff.schema.json | 4 ++-- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/crates/ruff/src/rules/flake8_type_checking/mod.rs b/crates/ruff/src/rules/flake8_type_checking/mod.rs index 31d0604184..2b90aa3f98 100644 --- a/crates/ruff/src/rules/flake8_type_checking/mod.rs +++ b/crates/ruff/src/rules/flake8_type_checking/mod.rs @@ -85,6 +85,7 @@ mod tests { Path::new("flake8_type_checking").join(path).as_path(), &settings::Settings { flake8_type_checking: super::settings::Settings { + runtime_evaluated_baseclasses: vec!["pydantic.BaseModel".to_string()], ..Default::default() }, ..settings::Settings::for_rule(rule_code) diff --git a/crates/ruff/src/rules/flake8_type_checking/settings.rs b/crates/ruff/src/rules/flake8_type_checking/settings.rs index 900e7f8e73..db45d3f96a 100644 --- a/crates/ruff/src/rules/flake8_type_checking/settings.rs +++ b/crates/ruff/src/rules/flake8_type_checking/settings.rs @@ -35,14 +35,14 @@ pub struct Options { /// blocks. pub exempt_modules: Option>, #[option( - default = "[\"pydantic.BaseModel\"]", + default = "[]", value_type = "list[str]", example = r#" runtime-evaluated-baseclasses = ["pydantic.BaseModel"] "# )] - /// Exempt type annotations of certain classes with base classes from needing to be moved into type-checking - /// blocks. + /// Exempt classes that list any of the enumerated classes as a base class + /// from needing to be moved into type-checking blocks. pub runtime_evaluated_baseclasses: Option>, #[option( default = "[]", @@ -51,8 +51,8 @@ pub struct Options { runtime-evaluated-decorators = ["attrs.define", "attrs.frozen"] "# )] - /// Exempt type annotations of certain classes with decorators from needing to be moved into type-checking - /// blocks. + /// Exempt classes decorated with any of the enumerated decorators from + /// needing to be moved into type-checking blocks. pub runtime_evaluated_decorators: Option>, } @@ -69,7 +69,7 @@ impl Default for Settings { Self { strict: false, exempt_modules: vec!["typing".to_string()], - runtime_evaluated_baseclasses: vec!["pydantic.BaseModel".to_string()], + runtime_evaluated_baseclasses: vec![], runtime_evaluated_decorators: vec![], } } @@ -84,7 +84,7 @@ impl From for Settings { .unwrap_or_else(|| vec!["typing".to_string()]), runtime_evaluated_baseclasses: options .runtime_evaluated_baseclasses - .unwrap_or_else(|| vec!["pydantic.BaseModel".to_string()]), + .unwrap_or_default(), runtime_evaluated_decorators: options.runtime_evaluated_decorators.unwrap_or_default(), } } diff --git a/ruff.schema.json b/ruff.schema.json index d3f5aae0b6..157ba1976f 100644 --- a/ruff.schema.json +++ b/ruff.schema.json @@ -909,7 +909,7 @@ } }, "runtime-evaluated-baseclasses": { - "description": "Exempt type annotations of certain classes with base classes from needing to be moved into type-checking blocks.", + "description": "Exempt classes that list any of the enumerated classes as a base class from needing to be moved into type-checking blocks.", "type": [ "array", "null" @@ -919,7 +919,7 @@ } }, "runtime-evaluated-decorators": { - "description": "Exempt type annotations of certain classes with decorators from needing to be moved into type-checking blocks.", + "description": "Exempt classes decorated with any of the enumerated decorators from needing to be moved into type-checking blocks.", "type": [ "array", "null"