Skip to content

Fix bare dict annotation handling#3433

Open
fengjikui wants to merge 1 commit into
openai:mainfrom
fengjikui:codex/bare-dict-annotations
Open

Fix bare dict annotation handling#3433
fengjikui wants to merge 1 commit into
openai:mainfrom
fengjikui:codex/bare-dict-annotations

Conversation

@fengjikui

Copy link
Copy Markdown

Fixes #3338.
Fixes #3341.

Summary

  • Treat bare dict annotations as unparameterized mappings in construct_type().
  • Preserve bare dict values during request transform instead of indexing missing type args.
  • Add regression coverage for bare dict handling in both model construction and sync/async transform paths.

Root Cause

Both code paths assumed dictionary annotations always include key/value type arguments, e.g. dict[str, T] or Dict[str, T]. A bare dict has no typing.get_args() entries, so indexing or unpacking those args raised IndexError / ValueError.

Validation

  • env HTTP_PROXY= HTTPS_PROXY= ALL_PROXY= NO_PROXY='*' http_proxy= https_proxy= all_proxy= no_proxy='*' uv run --with pytest --with pytest-asyncio --with pytest-xdist --with dirty-equals --with respx --with time-machine --with 'httpx[socks]' pytest tests/test_transform.py tests/test_models.py -q -> 117 passed
  • uv run --with ruff ruff format --check src/openai/_models.py src/openai/_utils/_transform.py tests/test_models.py tests/test_transform.py
  • uv run --with ruff ruff check src/openai/_models.py src/openai/_utils/_transform.py tests/test_models.py tests/test_transform.py
  • git diff --check

@fengjikui fengjikui requested a review from a team as a code owner June 23, 2026 22:01
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