Skip to content

fix: handle bare dict annotations in transform#3385

Open
Resurgamz wants to merge 1 commit into
openai:mainfrom
Resurgamz:fix/issue-3338-bare-dict-transform
Open

fix: handle bare dict annotations in transform#3385
Resurgamz wants to merge 1 commit into
openai:mainfrom
Resurgamz:fix/issue-3338-bare-dict-transform

Conversation

@Resurgamz

Copy link
Copy Markdown

Summary

  • Return bare dict values unchanged in request transform logic when no value type argument is available.
  • Add a sync/async regression test for TypedDict fields annotated as plain dict.

Changes

File Change
src/openai/_utils/_transform.py Guard dict value type lookup when get_args(dict) is empty.
tests/test_transform.py Cover bare dict fields in both sync and async transform paths.

Test Plan

  • PYTHONPATH="$PWD/src" /home/ut006460@uos/project/openai-python/.venv/bin/python -m pytest tests/test_transform.py -k bare_dict_typeddict_field -n 0
  • PYTHONPATH="$PWD/src" /home/ut006460@uos/project/openai-python/.venv/bin/python -m pytest tests/test_transform.py -n 0
  • /home/ut006460@uos/project/openai-python/.venv/bin/ruff format tests/test_transform.py src/openai/_utils/_transform.py
  • /home/ut006460@uos/project/openai-python/.venv/bin/ruff check tests/test_transform.py src/openai/_utils/_transform.py

Fixes #3338

Avoid indexing missing type arguments when request transform logic sees an unparameterized dict field.

Fixes openai#3338
@Resurgamz Resurgamz marked this pull request as ready for review June 9, 2026 01:43
@Resurgamz Resurgamz requested a review from a team as a code owner June 9, 2026 01:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

BUG: IndexError in _transform_recursive when TypedDict field uses bare dict annotation

1 participant