Add Pydantic's BaseConfig to default-copy list (#9650)

Closes https://github.com/astral-sh/ruff/issues/9647.
This commit is contained in:
Charlie Marsh 2024-01-26 06:54:48 -08:00 committed by GitHub
parent 79a0ddc112
commit b61b0edeea
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 13 additions and 1 deletions

View file

@ -67,3 +67,15 @@ class G(F):
without_annotation = []
class_variable: ClassVar[list[int]] = []
final_variable: Final[list[int]] = []
from pydantic import BaseConfig
class H(BaseModel):
class Config(BaseConfig):
mutable_default: list[int] = []
immutable_annotation: Sequence[int] = []
without_annotation = []
class_variable: ClassVar[list[int]] = []
final_variable: Final[list[int]] = []

View file

@ -59,7 +59,7 @@ pub(super) fn has_default_copy_semantics(
analyze::class::any_call_path(class_def, semantic, &|call_path| {
matches!(
call_path.as_slice(),
["pydantic", "BaseModel" | "BaseSettings"]
["pydantic", "BaseModel" | "BaseSettings" | "BaseConfig"]
| ["pydantic_settings", "BaseSettings"]
| ["msgspec", "Struct"]
)