@@ -173,6 +173,11 @@ def _transform_recursive(
173
173
# Iterable[T]
174
174
or (is_iterable_type (stripped_type ) and is_iterable (data ) and not isinstance (data , str ))
175
175
):
176
+ # dicts are technically iterable, but it is an iterable on the keys of the dict and is not usually
177
+ # intended as an iterable, so we don't transform it.
178
+ if isinstance (data , dict ):
179
+ return cast (object , data )
180
+
176
181
inner_type = extract_type_arg (stripped_type , 0 )
177
182
return [_transform_recursive (d , annotation = annotation , inner_type = inner_type ) for d in data ]
178
183
@@ -186,7 +191,7 @@ def _transform_recursive(
186
191
return data
187
192
188
193
if isinstance (data , pydantic .BaseModel ):
189
- return model_dump (data , exclude_unset = True )
194
+ return model_dump (data , exclude_unset = True , mode = "json" )
190
195
191
196
annotated_type = _get_annotated_type (annotation )
192
197
if annotated_type is None :
@@ -324,7 +329,7 @@ async def _async_transform_recursive(
324
329
return data
325
330
326
331
if isinstance (data , pydantic .BaseModel ):
327
- return model_dump (data , exclude_unset = True )
332
+ return model_dump (data , exclude_unset = True , mode = "json" )
328
333
329
334
annotated_type = _get_annotated_type (annotation )
330
335
if annotated_type is None :
0 commit comments