From e4cc44ad53a184f3b4363e73fa1bacd44fb84881 Mon Sep 17 00:00:00 2001 From: Stainless Bot <107565488+stainless-bot@users.noreply.github.com> Date: Tue, 2 Apr 2024 15:57:04 +0200 Subject: [PATCH] chore(internal): defer model build for import latency (#431) --- src/anthropic/_models.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/anthropic/_models.py b/src/anthropic/_models.py index 77c755b1..0f001150 100644 --- a/src/anthropic/_models.py +++ b/src/anthropic/_models.py @@ -1,5 +1,6 @@ from __future__ import annotations +import os import inspect from typing import TYPE_CHECKING, Any, Type, Union, Generic, TypeVar, Callable, cast from datetime import date, datetime @@ -38,6 +39,7 @@ is_given, is_mapping, parse_date, + coerce_boolean, parse_datetime, strip_not_given, extract_type_arg, @@ -74,7 +76,9 @@ class _ConfigProtocol(Protocol): class BaseModel(pydantic.BaseModel): if PYDANTIC_V2: - model_config: ClassVar[ConfigDict] = ConfigDict(extra="allow") + model_config: ClassVar[ConfigDict] = ConfigDict( + extra="allow", defer_build=coerce_boolean(os.environ.get("DEFER_PYDANTIC_BUILD", "true")) + ) else: @property