File tree Expand file tree Collapse file tree 1 file changed +5
-1
lines changed
Expand file tree Collapse file tree 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
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 :]
You can’t perform that action at this time.
0 commit comments