feat: improve future compat with pydantic v3

This commit is contained in:
stainless-app[bot] 2025-09-04 02:54:45 +00:00
parent 979c43dbc7
commit 5d58a795ce
13 changed files with 437 additions and 137 deletions

View file

@ -59,7 +59,7 @@ from ._types import (
ModelBuilderProtocol,
)
from ._utils import is_dict, is_list, asyncify, is_given, lru_cache, is_mapping
from ._compat import PYDANTIC_V2, model_copy, model_dump
from ._compat import PYDANTIC_V1, model_copy, model_dump
from ._models import GenericModel, FinalRequestOptions, validate_type, construct_type
from ._response import (
APIResponse,
@ -232,7 +232,7 @@ class BaseSyncPage(BasePage[_T], Generic[_T]):
model: Type[_T],
options: FinalRequestOptions,
) -> None:
if PYDANTIC_V2 and getattr(self, "__pydantic_private__", None) is None:
if (not PYDANTIC_V1) and getattr(self, "__pydantic_private__", None) is None:
self.__pydantic_private__ = {}
self._model = model
@ -320,7 +320,7 @@ class BaseAsyncPage(BasePage[_T], Generic[_T]):
client: AsyncAPIClient,
options: FinalRequestOptions,
) -> None:
if PYDANTIC_V2 and getattr(self, "__pydantic_private__", None) is None:
if (not PYDANTIC_V1) and getattr(self, "__pydantic_private__", None) is None:
self.__pydantic_private__ = {}
self._model = model