From 4b818e77ecab5ec3237801445f81117b4467d2ba Mon Sep 17 00:00:00 2001 From: stainless-bot Date: Wed, 20 Mar 2024 14:50:16 +0000 Subject: [PATCH] feat(api): OpenAPI spec update via Stainless API --- src/cloudflare/_models.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/cloudflare/_models.py b/src/cloudflare/_models.py index 166973538fa..35a23a95cce 100644 --- a/src/cloudflare/_models.py +++ b/src/cloudflare/_models.py @@ -290,11 +290,15 @@ def is_basemodel_type(type_: type) -> TypeGuard[type[BaseModel] | type[GenericMo return issubclass(origin, BaseModel) or issubclass(origin, GenericModel) -def construct_type(*, value: object, type_: type) -> object: +def construct_type(*, value: object, type_: object) -> object: """Loose coercion to the expected type with construction of nested values. If the given value does not match the expected type then it is returned as-is. """ + # we allow `object` as the input type because otherwise, passing things like + # `Literal['value']` will be reported as a type error by type checkers + type_ = cast("type[object]", type_) + # unwrap `Annotated[T, ...]` -> `T` if is_annotated_type(type_): meta = get_args(type_)[1:]