Skip to content

Commit

Permalink
fix(python): patch v1_on_v2 pydantic utilities (#5426)
Browse files Browse the repository at this point in the history
* fix(python): patch v1_on_v2 pydantic utilities

* updated seeds

---------

Co-authored-by: eden wang <[email protected]>
  • Loading branch information
matthew-giglio and eyw520 authored Dec 23, 2024
1 parent 2359122 commit 3f2de00
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@

def parse_obj_as(type_: typing.Type[T], object_: typing.Any) -> T:
dealiased_object = convert_and_respect_annotation_metadata(object_=object_, annotation=type_, direction="read")
return pydantic.parse_obj_as(type_, dealiased_object)
return pydantic.v1.parse_obj_as(type_, dealiased_object)


def to_jsonable_with_fallback(
Expand Down Expand Up @@ -173,14 +173,14 @@ def universal_root_validator(
pre: bool = False,
) -> typing.Callable[[AnyCallable], AnyCallable]:
def decorator(func: AnyCallable) -> AnyCallable:
return pydantic.root_validator(pre=pre)(func) # type: ignore # Pydantic v1
return pydantic.v1.root_validator(pre=pre)(func) # type: ignore # Pydantic v1

return decorator


def universal_field_validator(field_name: str, pre: bool = False) -> typing.Callable[[AnyCallable], AnyCallable]:
def decorator(func: AnyCallable) -> AnyCallable:
return pydantic.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1
return pydantic.v1.validator(field_name, pre=pre)(func) # type: ignore # Pydantic v1

return decorator

Expand Down

0 comments on commit 3f2de00

Please sign in to comment.