diff --git a/crates/ruff/src/rules/ruff/rules/helpers.rs b/crates/ruff/src/rules/ruff/rules/helpers.rs index 9643508cb7..944b1b52a2 100644 --- a/crates/ruff/src/rules/ruff/rules/helpers.rs +++ b/crates/ruff/src/rules/ruff/rules/helpers.rs @@ -37,11 +37,14 @@ pub(super) fn is_dataclass(class_def: &ast::StmtClassDef, semantic: &SemanticMod }) } -/// Returns `true` if the given class is a Pydantic `BaseModel`. +/// Returns `true` if the given class is a Pydantic `BaseModel` or `BaseSettings` subclass. pub(super) fn is_pydantic_model(class_def: &ast::StmtClassDef, semantic: &SemanticModel) -> bool { class_def.bases.iter().any(|expr| { semantic.resolve_call_path(expr).map_or(false, |call_path| { - matches!(call_path.as_slice(), ["pydantic", "BaseModel"]) + matches!( + call_path.as_slice(), + ["pydantic", "BaseModel" | "BaseSettings"] + ) }) }) }