From 1567827af40fc79ea8927ce04be00520bf39c0d2 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 20 Mar 2024 14:50:23 +0000 Subject: [PATCH] feat(api): OpenAPI spec update via Stainless API (#153) --- 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:]