Skip to content

Commit fc8b4c3

Browse files
chore(internal): loosen input type for util function (#1250)
1 parent 5cfb125 commit fc8b4c3

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/openai/_models.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -290,11 +290,15 @@ def is_basemodel_type(type_: type) -> TypeGuard[type[BaseModel] | type[GenericMo
290290
return issubclass(origin, BaseModel) or issubclass(origin, GenericModel)
291291

292292

293-
def construct_type(*, value: object, type_: type) -> object:
293+
def construct_type(*, value: object, type_: object) -> object:
294294
"""Loose coercion to the expected type with construction of nested values.
295295
296296
If the given value does not match the expected type then it is returned as-is.
297297
"""
298+
# we allow `object` as the input type because otherwise, passing things like
299+
# `Literal['value']` will be reported as a type error by type checkers
300+
type_ = cast("type[object]", type_)
301+
298302
# unwrap `Annotated[T, ...]` -> `T`
299303
if is_annotated_type(type_):
300304
meta = get_args(type_)[1:]

0 commit comments

Comments
 (0)