mirror of https://github.com/tiangolo/fastapi.git
♻️ Update internal checks to support Pydantic 2.10 (#12914)
This commit is contained in:
parent
f716490823
commit
91a929319c
|
|
@ -27,7 +27,8 @@ from typing_extensions import Annotated, Literal, get_args, get_origin
|
|||
|
||||
# Reassign variable to make it reexported for mypy
|
||||
PYDANTIC_VERSION = P_VERSION
|
||||
PYDANTIC_V2 = PYDANTIC_VERSION.startswith("2.")
|
||||
PYDANTIC_VERSION_MINOR_TUPLE = tuple(int(x) for x in PYDANTIC_VERSION.split(".")[:2])
|
||||
PYDANTIC_V2 = PYDANTIC_VERSION_MINOR_TUPLE[0] == 2
|
||||
|
||||
|
||||
sequence_annotation_to_type = {
|
||||
|
|
|
|||
|
|
@ -6,7 +6,11 @@ from fastapi.openapi.models import Example
|
|||
from pydantic.fields import FieldInfo
|
||||
from typing_extensions import Annotated, deprecated
|
||||
|
||||
from ._compat import PYDANTIC_V2, PYDANTIC_VERSION, Undefined
|
||||
from ._compat import (
|
||||
PYDANTIC_V2,
|
||||
PYDANTIC_VERSION_MINOR_TUPLE,
|
||||
Undefined,
|
||||
)
|
||||
|
||||
_Unset: Any = Undefined
|
||||
|
||||
|
|
@ -105,7 +109,7 @@ class Param(FieldInfo):
|
|||
stacklevel=4,
|
||||
)
|
||||
current_json_schema_extra = json_schema_extra or extra
|
||||
if PYDANTIC_VERSION < "2.7.0":
|
||||
if PYDANTIC_VERSION_MINOR_TUPLE < (2, 7):
|
||||
self.deprecated = deprecated
|
||||
else:
|
||||
kwargs["deprecated"] = deprecated
|
||||
|
|
@ -561,7 +565,7 @@ class Body(FieldInfo):
|
|||
stacklevel=4,
|
||||
)
|
||||
current_json_schema_extra = json_schema_extra or extra
|
||||
if PYDANTIC_VERSION < "2.7.0":
|
||||
if PYDANTIC_VERSION_MINOR_TUPLE < (2, 7):
|
||||
self.deprecated = deprecated
|
||||
else:
|
||||
kwargs["deprecated"] = deprecated
|
||||
|
|
|
|||
Loading…
Reference in New Issue