From 2005076f500bef6e0a6cc8f935b9cc9fef65ab5b Mon Sep 17 00:00:00 2001 From: Stainless Bot <107565488+stainless-bot@users.noreply.github.com> Date: Mon, 18 Mar 2024 16:51:42 -0400 Subject: [PATCH] perf: cache TypeAdapters (#1243) --- src/openai/_models.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/openai/_models.py b/src/openai/_models.py index 4aa2623bbc..166973538f 100644 --- a/src/openai/_models.py +++ b/src/openai/_models.py @@ -534,12 +534,12 @@ class GenericModel(BaseGenericModel, BaseModel): if PYDANTIC_V2: - if TYPE_CHECKING: - from pydantic import TypeAdapter + from pydantic import TypeAdapter else: - from pydantic import TypeAdapter as _TypeAdapter - TypeAdapter = lru_cache(_TypeAdapter) + from pydantic import TypeAdapter as _TypeAdapter + + TypeAdapter = lru_cache(_TypeAdapter) def _validate_non_model_type(*, type_: type[_T], value: object) -> _T: return TypeAdapter(type_).validate_python(value)