Skip to content

Commit 6a3e5c5

Browse files
fix: don't use dicts as iterables in transform (openai#1842)
1 parent 9eb05c1 commit 6a3e5c5

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/openai/_utils/_transform.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,11 @@ def _transform_recursive(
173173
# Iterable[T]
174174
or (is_iterable_type(stripped_type) and is_iterable(data) and not isinstance(data, str))
175175
):
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+
176181
inner_type = extract_type_arg(stripped_type, 0)
177182
return [_transform_recursive(d, annotation=annotation, inner_type=inner_type) for d in data]
178183

0 commit comments

Comments
 (0)