Skip to content

Commit 76a51b1

Browse files
stainless-app[bot]stainless-bot
authored andcommitted
fix: don't use dicts as iterables in transform (#1865)
1 parent adafe08 commit 76a51b1

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/openai/_utils/_transform.py

+5
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,11 @@ async def _async_transform_recursive(
316316
# Iterable[T]
317317
or (is_iterable_type(stripped_type) and is_iterable(data) and not isinstance(data, str))
318318
):
319+
# dicts are technically iterable, but it is an iterable on the keys of the dict and is not usually
320+
# intended as an iterable, so we don't transform it.
321+
if isinstance(data, dict):
322+
return cast(object, data)
323+
319324
inner_type = extract_type_arg(stripped_type, 0)
320325
return [await _async_transform_recursive(d, annotation=annotation, inner_type=inner_type) for d in data]
321326

0 commit comments

Comments
 (0)