Pydantic v2 ModelConfig
option to deepcopy
on construction?
#9313
jamesbraza
started this conversation in
Pydantic V2
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Pydantic v1's model configuration had
copy_on_model_validation
(docs) which configured shallow vs deepcopy vs none on construction. Pydantic v2 removed this, and now hasrevalidate_instances
(docs). It seems Pydantic v2 by default does a shallow copy on model construction.When dealing with Pydantic v2 models containing nested
BaseModel
, the default shallow copy doesn't deeply copy the nestedBaseModel
.Is there some way to configure a Pydantic v2 object to deepcopy during construction?
Beta Was this translation helpful? Give feedback.
All reactions