File tree 1 file changed +5
-1
lines changed
1 file changed +5
-1
lines changed Original file line number Diff line number Diff line change @@ -290,11 +290,15 @@ def is_basemodel_type(type_: type) -> TypeGuard[type[BaseModel] | type[GenericMo
290
290
return issubclass (origin , BaseModel ) or issubclass (origin , GenericModel )
291
291
292
292
293
- def construct_type (* , value : object , type_ : type ) -> object :
293
+ def construct_type (* , value : object , type_ : object ) -> object :
294
294
"""Loose coercion to the expected type with construction of nested values.
295
295
296
296
If the given value does not match the expected type then it is returned as-is.
297
297
"""
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
+
298
302
# unwrap `Annotated[T, ...]` -> `T`
299
303
if is_annotated_type (type_ ):
300
304
meta = get_args (type_ )[1 :]
You can’t perform that action at this time.
0 commit comments