diff --git a/crates/ruff_linter/resources/test/fixtures/ruff/RUF012.py b/crates/ruff_linter/resources/test/fixtures/ruff/RUF012.py index ef58e45df1cb4..aa9d54d8b7bdd 100644 --- a/crates/ruff_linter/resources/test/fixtures/ruff/RUF012.py +++ b/crates/ruff_linter/resources/test/fixtures/ruff/RUF012.py @@ -48,3 +48,14 @@ class E(Struct): without_annotation = [] class_variable: ClassVar[list[int]] = [] final_variable: Final[list[int]] = [] + + +from pydantic_settings import BaseSettings + + +class F(BaseSettings): + mutable_default: list[int] = [] + immutable_annotation: Sequence[int] = [] + without_annotation = [] + class_variable: ClassVar[list[int]] = [] + final_variable: Final[list[int]] = [] diff --git a/crates/ruff_linter/src/rules/ruff/rules/helpers.rs b/crates/ruff_linter/src/rules/ruff/rules/helpers.rs index 78caf8d18fb5d..6cf01db9db998 100644 --- a/crates/ruff_linter/src/rules/ruff/rules/helpers.rs +++ b/crates/ruff_linter/src/rules/ruff/rules/helpers.rs @@ -65,7 +65,9 @@ pub(super) fn has_default_copy_semantics( semantic.resolve_call_path(expr).is_some_and(|call_path| { matches!( call_path.as_slice(), - ["pydantic", "BaseModel" | "BaseSettings"] | ["msgspec", "Struct"] + ["pydantic", "BaseModel" | "BaseSettings"] + | ["pydantic_settings", "BaseSettings"] + | ["msgspec", "Struct"] ) }) })