[python] add support for exact client name#10750
Merged
Merged
Conversation
Contributor
|
All changed packages have been documented.
|
commit: |
|
You can try these changes here
|
Member
|
That's awesome! thank you @iscai-msft !!! |
tadelesh
reviewed
May 21, 2026
Member
tadelesh
left a comment
There was a problem hiding this comment.
Can we move the judgement to a helper function and do not repeat in every place?
Co-authored-by: Copilot <[email protected]>
tadelesh
approved these changes
May 22, 2026
timotheeguerin
approved these changes
May 22, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
Adds support in the Python emitter/generator pipeline for “exact” client names so a @clientName(exact("..."), "python") override can bypass snake_case conversion and reserved-word padding (notably enabling stream without auto-suffixing).
Changes:
- Emit and propagate an
isExactNameflag for parameters/properties and use it to choose between exact vs snake_case client naming. - Update Python preprocessing/codegen to skip lowercasing/padding when
isExactNameis set, and avoid consuming the internalstreamkwarg when a parameter is exactly namedstream. - Add a Chronus changelog entry for
@typespec/http-client-python.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/http-client-python/generator/pygen/preprocess/init.py | Skips lowercasing/padding for exact names; updates property-to-parameter mapping handling. |
| packages/http-client-python/generator/pygen/codegen/serializers/builder_serializer.py | Attempts to adjust kwargs popping behavior for exact-name params. |
| packages/http-client-python/generator/pygen/codegen/models/parameter.py | Adds is_exact_name on parameters from YAML. |
| packages/http-client-python/generator/pygen/codegen/models/operation.py | Adds exact_name_params helper and uses it to avoid stream kwarg consumption. |
| packages/http-client-python/emitter/src/utils.ts | Introduces getClientName() helper and includes isExactName in param base emission. |
| packages/http-client-python/emitter/src/types.ts | Emits model property isExactName and uses getClientName() for property client names. |
| packages/http-client-python/emitter/src/http.ts | Propagates isExactName for flattened/body parameters and uses getClientName() for body param naming. |
| .chronus/changes/python-addExactSupport-2026-4-20-15-34-6.md | Adds changelog entry for the feature. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
cc @dargilco @howieleung
Once this is in, you can add
@clientName(exact("stream"), "python")to your stream parameter and it won't get padded. It will also help with other instances where you don't want case conversion or padding. We will generate exactly what's passed into theexactfunction, we won't do any snake casing either.