Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Copy on model validation #62

Open
orfisko opened this issue Jul 8, 2023 · 0 comments
Open

Copy on model validation #62

orfisko opened this issue Jul 8, 2023 · 0 comments

Comments

@orfisko
Copy link
Contributor

orfisko commented Jul 8, 2023

I had a copy_on_model_validation flag set to "none" on my pydantic models and could not find any documentation on the migration page on how to deal with this setting in v2. Seems from v1 discussions on issues raised on github that this is now irrelevant since Pydantic will never copy anymore when validating models, also considered by @PrettyWood to be incorrect behaviour.

Could save other people quite some time if this would make it to the pydantic migration docs and/or flagged by bump-pydantic as a superfluous setting now

class DefaultBaseModel(BaseModel):
-    class Config:
-        arbitrary_types_allowed = True
-        copy_on_model_validation = "none"
-        validate_assignment = True
+    # TODO: The following keys were removed: `copy_on_model_validation`.
+    # Check https://docs.pydantic.dev/dev-v2/migration/#changes-to-config for more information.
+    model_config = ConfigDict(arbitrary_types_allowed=True, copy_on_model_validation="none", validate_assignment=True)

In the ConfigDict this setting should not even be included anymore, it won't work either I presume.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant