Skip to content

fix: handle bare dict type annotations#3376

Open
he-yufeng wants to merge 1 commit into
openai:mainfrom
he-yufeng:fix/bare-dict-type-handling
Open

fix: handle bare dict type annotations#3376
he-yufeng wants to merge 1 commit into
openai:mainfrom
he-yufeng:fix/bare-dict-type-handling

Conversation

@he-yufeng
Copy link
Copy Markdown

Summary

  • avoid indexing get_args() when request transform sees a bare dict annotation
  • avoid unpacking empty get_args() in construct_type(..., type_=dict)
  • add regressions for sync/async transform and model construction with unparameterized dict

Fixes #3338.
Fixes #3341.

Tested

  • Reproduced both failures locally before the patch with PYTHONPATH=src.
  • python -m pytest tests\test_transform.py::test_bare_dictionary_annotation tests\test_transform.py::test_dictionary_items tests\test_models.py::test_construct_bare_dict_type -q
  • python -m pytest tests\test_transform.py tests\test_models.py -q
  • python -m py_compile src\openai\_utils\_transform.py src\openai\_models.py tests\test_transform.py tests\test_models.py
  • python -m ruff check src\openai\_utils\_transform.py src\openai\_models.py tests\test_transform.py tests\test_models.py
  • python -m ruff format --check src\openai\_utils\_transform.py src\openai\_models.py tests\test_transform.py tests\test_models.py
  • git diff --check

@he-yufeng he-yufeng requested a review from a team as a code owner June 7, 2026 16:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant