fix(python): wrap non-string global header values with str()#15074
fix(python): wrap non-string global header values with str()#15074patrickthornton wants to merge 3 commits intomainfrom
Conversation
There was a problem hiding this comment.
Claude Code Review
This repository is configured for manual code reviews. Comment @claude review to trigger a review and subscribe this PR to future pushes, or @claude review once for a one-time review.
Tip: disable this comment in your organization's Code Review settings.
🌱 Seed Test SelectorSelect languages to run seed tests for:
How to use: Click the ⋯ menu above → "Edit" → check the boxes you want → click "Update comment". Tests will run automatically and snapshots will be committed to this PR. |
SDK Generation Benchmark ResultsComparing PR branch against latest nightly baseline on Full benchmark table (click to expand)
main (generator): generator-only time via --skip-scripts (includes Docker image build, container startup, IR parsing, and code generation — this is the same Docker-based flow customers use via |
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Description
Fixes a
mypyfailure in the generated Python SDK when an API declares a non-string global header (e.g.Request-Timeout: integer, as used by Vectara).The generator emits
headers: Dict[str, str]but previously assigned the raw typed member directly, producing:No existing seed fixture declared a non-string global header, so the code path was never exercised.
Changes Made
is_type_reference_stringhelper inclient_generator/type_utilities.pythat unwrapsOptional/nullable/alias to detect the underlying primitive.needs_str_conversionflag onConstructorParameterincore_utilities/client_wrapper_generator.py, set when the header's Fern IR type is not a string._get_write_get_headers_bodyto wrap the RHS withstr(...)only whenneeds_str_conversionis True — string-typed headers are emitted unchanged to avoid snapshot churn across existing fixtures.generators/python/sdk/versions.ymlas5.4.0-rc.2.Generated code now produces:
Testing
Regenerated the Vectara SDK against
/Users/Patrick/configs/vectara-fern-config/fernusingpnpm seed run --generator python-sdk --skipScripts, then ran the generated project's CI workflow locally:poetry run mypy .— Success: no issues found in 906 source filespoetry run pytest -rP -n auto .— 49 passed, 4 skippedpoetry install --extras aiohttp && poetry run pytest -rP -n auto -m aiohttp .— 3 passedUnit tests added/updated
Manual testing completed