# Reassign variable to make it reexported for mypy
PYDANTIC_VERSION = P_VERSION
-IS_PYDANTIC_V2 = PYDANTIC_VERSION.startswith("2.")
+PYDANTIC_MINOR_VERSION = tuple(int(i) for i in P_VERSION.split(".")[:2])
+IS_PYDANTIC_V2 = PYDANTIC_MINOR_VERSION[0] == 2
if TYPE_CHECKING:
from ._compat import ( # type: ignore[attr-defined]
IS_PYDANTIC_V2,
- PYDANTIC_VERSION,
+ PYDANTIC_MINOR_VERSION,
BaseConfig,
ModelField,
ModelMetaclass,
warnings: Union[bool, Literal["none", "warn", "error"]] = True,
serialize_as_any: bool = False,
) -> Dict[str, Any]:
- if PYDANTIC_VERSION >= "2.7.0":
+ if PYDANTIC_MINOR_VERSION >= (2, 7):
extra_kwargs: Dict[str, Any] = {
"context": context,
"serialize_as_any": serialize_as_any,