Skip to content

Fix bare dict annotation handling - #3433

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

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
Contributor

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

Copy link
Copy Markdown
Contributor

Thank you for the contribution. The missing type arguments for bare dict annotations are now handled in model construction and sync/async request transformation by #3760, which is merged into main.

Closing this PR because the merged change resolves the same crash. Please use a release containing #3760 when available; the fix is not included in v3.11.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants