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

Fix deprecation warnings around "copy_on_model_validation" #927

Merged
merged 3 commits into from Nov 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 7 additions & 1 deletion datamodel_code_generator/reference.py
Expand Up @@ -29,6 +29,8 @@
)

import inflect
import pydantic
from packaging import version
from pydantic import BaseModel, validator

from datamodel_code_generator import cached_property
Expand Down Expand Up @@ -92,7 +94,11 @@ def validate_original_name(cls, v: Any, values: Dict[str, Any]) -> str:
class Config:
arbitrary_types_allowed = True
keep_untouched = (cached_property,)
copy_on_model_validation = False
copy_on_model_validation = (
False
if version.parse(pydantic.VERSION) < version.parse('1.9.2')
else 'none'
)

@property
def short_name(self) -> str:
Expand Down
10 changes: 8 additions & 2 deletions datamodel_code_generator/types.py
Expand Up @@ -21,6 +21,8 @@
Union,
)

import pydantic
from packaging import version
from pydantic import StrictBool, StrictInt, StrictStr, create_model

from datamodel_code_generator import Protocol, runtime_checkable
Expand Down Expand Up @@ -64,8 +66,12 @@ def module_name(self) -> str:

class DataType(_BaseModel):
class Config:
extra = "forbid"
copy_on_model_validation = False
extra = 'forbid'
copy_on_model_validation = (
False
if version.parse(pydantic.VERSION) < version.parse('1.9.2')
else 'none'
)

type: Optional[str]
reference: Optional[Reference]
Expand Down