Commit 643e500c

stainless-app[bot] <142633134+stainless-app[bot]@users.noreply.github.com>
2024-11-02 10:46:36
fix: don't use dicts as iterables in transform (#1842)
1 parent c94ead1
Changed files (1)
src
openai
src/openai/_utils/_transform.py
@@ -173,6 +173,11 @@ def _transform_recursive(
         # Iterable[T]
         or (is_iterable_type(stripped_type) and is_iterable(data) and not isinstance(data, str))
     ):
+        # dicts are technically iterable, but it is an iterable on the keys of the dict and is not usually
+        # intended as an iterable, so we don't transform it.
+        if isinstance(data, dict):
+            return cast(object, data)
+
         inner_type = extract_type_arg(stripped_type, 0)
         return [_transform_recursive(d, annotation=annotation, inner_type=inner_type) for d in data]