# 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 = {
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
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
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