Skip to content

Commit bd6b60b

Browse files
committed
fixing deprecated pydantic calls
1 parent b1fedf9 commit bd6b60b

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

deepdiff/helper.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -733,13 +733,17 @@ def detailed__dict__(obj, ignore_private_variables=True, ignore_keys=frozenset()
733733
ignore_private_variables and key.startswith('__') and not key.startswith(private_var_prefix)
734734
):
735735
del result[key]
736+
if isinstance(obj, PydanticBaseModel):
737+
getter = lambda x, y: getattr(type(x), y)
738+
else:
739+
getter = getattr
736740
for key in dir(obj):
737741
if key not in result and key not in ignore_keys and (
738742
not ignore_private_variables or (
739743
ignore_private_variables and not key.startswith('__') and not key.startswith(private_var_prefix)
740744
)
741745
):
742-
value = getattr(obj, key)
746+
value = getter(obj, key)
743747
if not callable(value):
744748
result[key] = value
745749
return result

deepdiff/serialization.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -616,7 +616,7 @@ def _serialize_tuple(value):
616616
}
617617

618618
if PydanticBaseModel is not pydantic_base_model_type:
619-
JSON_CONVERTOR[PydanticBaseModel] = lambda x: x.dict()
619+
JSON_CONVERTOR[PydanticBaseModel] = lambda x: x.model_dump()
620620

621621

622622
def json_convertor_default(default_mapping=None):

0 commit comments

Comments
 (0)