🐛 Fix: 修改遗漏的过时 Pydantic 方法 (#2577)

This commit is contained in:
Ju4tCode
2024-02-16 21:16:46 +08:00
committed by GitHub
parent 5ab418a3cf
commit ffbd1f9aeb
6 changed files with 24 additions and 13 deletions

View File

@ -194,8 +194,9 @@ if PYDANTIC_V2: # pragma: pydantic-v2
model: BaseModel,
include: Optional[Set[str]] = None,
exclude: Optional[Set[str]] = None,
by_alias: bool = False,
) -> Dict[str, Any]:
return model.model_dump(include=include, exclude=exclude)
return model.model_dump(include=include, exclude=exclude, by_alias=by_alias)
def type_validate_python(type_: Type[T], data: Any) -> T:
"""Validate data with given type."""
@ -339,8 +340,9 @@ else: # pragma: pydantic-v1
model: BaseModel,
include: Optional[Set[str]] = None,
exclude: Optional[Set[str]] = None,
by_alias: bool = False,
) -> Dict[str, Any]:
return model.dict(include=include, exclude=exclude)
return model.dict(include=include, exclude=exclude, by_alias=by_alias)
def type_validate_python(type_: Type[T], data: Any) -> T:
"""Validate data with given type."""