fix(http-client-python): removing duplicate union aliases and preserve overload parameter types - #12017
fix(http-client-python): removing duplicate union aliases and preserve overload parameter types#12017Libba Lawrence (l0lawrence) wants to merge 10 commits into
Conversation
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
commit: |
There was a problem hiding this comment.
🟢 Approval recommended
No unresolved review issues remain, and validation passed.
Pull request overview
Fixes Python generator regressions involving named unions, overload type alignment, and ETag handling.
Changes:
- Deduplicates named union aliases.
- Preserves parameter types after flattening.
- Handles required and optional ETag APIs correctly.
- Adds focused regression tests and changelog documentation.
File summaries
| File | Reviewed change |
|---|---|
packages/http-client-python/tests/unit/test_typeddict.py |
Tests duplicate alias elimination. |
packages/http-client-python/tests/unit/test_typeddict_overloads.py |
Tests overload type preservation. |
packages/http-client-python/tests/unit/test_preprocess_etag.py |
Tests required and optional ETag behavior. |
packages/http-client-python/generator/pygen/preprocess/__init__.py |
Updates overload typing and ETag preprocessing. |
packages/http-client-python/generator/pygen/codegen/templates/unions.py.jinja2 |
Renders deduplicated unions. |
packages/http-client-python/generator/pygen/codegen/serializers/unions_serializer.py |
Deduplicates named unions. |
.chronus/changes/python-union-etag-regressions-2026-09-18.md |
Records the package fix. |
Review details
- Files reviewed: 7/7 changed files
- Comments generated: 0
- Review effort level: Lite
💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
|
All changed packages have been documented.
Show changes
|
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Python emitter diffBaseline No changes to generated output. Rendered diff: inline on the run summary, or the emitter-diff-html artifact. Informational check (eng/emitter-diff); does not block the PR. |
|
You can try these changes here
|
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Collapse duplicate named unions by alias name using an insertion-ordered dict instead of raising on conflicting definitions. Update the test to assert a single alias is emitted (first wins). Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Synthesize the missing ETag partner as a real wire header with canonical HTTP casing (If-Match/If-None-Match) instead of a non-wire keyword parameter. At most one side serializes per call, gated by match_condition, so no undeclared header is sent. Remove the now-dead per-overload etag recursion (overloads inherit the reconciled pair via add_overload's deep copy) and revert the keyword-only method_location special case. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Scope the PR to two fixes: deduplicate named union aliases, and reattach shared parameter type objects before filtering flattened parameters in add_overload so trailing parameter types are not shifted. Removes the earlier conditional-header casing synthesis change and its tests. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Fixes two more bugs in the Python emitter (
@typespec/http-client-python, pygen) surfaced in generatedazure-ai-projectsSDK code:_unions.pycould emit the same named union alias more than once.UnionsSerializer.named_unionsnow deduplicates by alias name so each named union produces a singleTypeAliasdeclaration.add_overloadfiltered out flattened body parameters before reattaching shared type objects, sozip-based positional alignment against the original operation could assign the wrongtypeto trailing parameters. The type reattachment now runs before the flattened-parameter filter, preserving correct types on the remaining parameters.Note
If-Match/If-None-Match). when an operation declares one of the conditional headers we add its pair since MatchConditions can be selected