Coverage for src/dynapydantic/version_check.py: 100%
14 statements
« prev ^ index » next coverage.py v7.15.4, created at 2026-09-06 00:44 +0000
« prev ^ index » next coverage.py v7.15.4, created at 2026-09-06 00:44 +0000
1"""Version checking utilities."""
3import pydantic
6def pydantic_le(version: tuple[int, ...]) -> bool:
7 """Test whether the pydantic version is <= ``version``."""
8 return _pydantic_version() <= version
11def pydantic_lt(version: tuple[int, ...]) -> bool:
12 """Test whether the pydantic version is < ``version``."""
13 return _pydantic_version() < version
16def pydantic_ge(version: tuple[int, ...]) -> bool:
17 """Test whether the pydantic version is >= ``version``."""
18 return _pydantic_version() >= version
21def pydantic_gt(version: tuple[int, ...]) -> bool:
22 """Test whether the pydantic version is > ``version``."""
23 return _pydantic_version() > version
26_PYDANTIC_VERSION: tuple[int, ...] | None = None
29def _pydantic_version() -> tuple[int, ...]:
30 global _PYDANTIC_VERSION # noqa: PLW0603
32 if _PYDANTIC_VERSION is None:
33 _PYDANTIC_VERSION = tuple(int(x) for x in pydantic.__version__.split("."))
35 return _PYDANTIC_VERSION