Skip to content

Fix Python schema conversion for variadic tuples with union elements - #437

Open
林SO (Linxiushen) wants to merge 1 commit into
microsoft:mainfrom
Linxiushen:fix/variadic-tuple-union-schema
Open

林SO (Linxiushen) wants to merge 1 commit into
microsoft:mainfrom
Linxiushen:fix/variadic-tuple-union-schema

Conversation

@Linxiushen

Copy link
Copy Markdown

The Python schema converter raises AssertionError for variadic tuples whose elements are unions, such as tuple[int | str, ...], tuple[str | None, ...], or tuple[Literal["yes", "no"], ...]. This also prevents constructing a TypeChatJsonTranslator for a dataclass containing these fields.

Render these element types as Array<...>, matching the existing handling of lists with union elements. Extend the tuple schema snapshot with union, nullable, literal, and nested cases, and add a translator regression that validates a fixed JSON response into the expected Python tuples.

Validation on Python 3.12:

  • The schema and translator regressions fail against the unchanged base; five existing translator tests pass.
  • Full Python suite: 23 passed, including all 17 snapshots.
  • Repository-pinned Pyright 1.1.358: 0 errors and 0 warnings across the Python project.
  • git diff --check passes.

The translator test uses the existing fixed-response model; no live provider calls were made.

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.

1 participant