-
-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
96 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
from pydantic import BaseModel, <warning descr="Pydantic V2 Migration Guide: https://docs.pydantic.dev/dev-v2/migration/">validator</warning>, <warning descr="Pydantic V2 Migration Guide: https://docs.pydantic.dev/dev-v2/migration/">root_validator</warning> | ||
|
||
def check(func): | ||
def inner(): | ||
func() | ||
return inner | ||
|
||
class A(BaseModel): | ||
a: str | ||
|
||
|
||
@<warning descr="Pydantic V2 Migration Guide: https://docs.pydantic.dev/dev-v2/migration/">validator</warning>('a') | ||
def validate_a(cls): | ||
pass | ||
|
||
@<warning descr="Pydantic V2 Migration Guide: https://docs.pydantic.dev/dev-v2/migration/">root_validator</warning>() | ||
def validate_root(cls): | ||
pass | ||
|
||
|
||
def dummy(self): | ||
pass | ||
|
||
@check | ||
def task(self): | ||
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from class_validators import validator, root_validator |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
from warnings import warn | ||
|
||
from ..warnings import PydanticDeprecatedSince20 | ||
|
||
DeprecationWarning = PydanticDeprecatedSince20 | ||
|
||
|
||
def validator( | ||
__field: str, | ||
*fields: str, | ||
pre: bool = False, | ||
each_item: bool = False, | ||
always: bool = False, | ||
check_fields: bool | None = None, | ||
allow_reuse: bool = False, | ||
) -> Callable[[_V1ValidatorType], _V1ValidatorType]: | ||
|
||
warn( | ||
'Pydantic V1 style `@validator` validators are deprecated.' | ||
' You should migrate to Pydantic V2 style `@field_validator` validators,' | ||
' see the migration guide for more details', | ||
DeprecationWarning, | ||
stacklevel=2, | ||
) | ||
|
||
|
||
def root_validator( | ||
*__args, | ||
pre: bool = False, | ||
skip_on_failure: bool = False, | ||
allow_reuse: bool = False, | ||
) -> Any: | ||
warn( | ||
'Pydantic V1 style `@root_validator` validators are deprecated.' | ||
' You should migrate to Pydantic V2 style `@model_validator` validators,' | ||
' see the migration guide for more details', | ||
DeprecationWarning, | ||
stacklevel=2, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters