Skip to content

[python] add support for exact client name - #10750

Merged
iscai-msft merged 4 commits into
microsoft:mainfrom
iscai-msft:python/addExactSupport
May 26, 2026
Merged

iscai-msft merged 4 commits into
microsoft:mainfrom
iscai-msft:python/addExactSupport

Conversation

@iscai-msft

@iscai-msft iscai-msft commented May 20, 2026 •

Copy link
Copy Markdown
Member

cc Darren Cohen (@dargilco) Howie Leung (@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 the exact function, we won't do any snake casing either.

for Azure/typespec-azure#4470

@github-actions

github-actions Bot commented May 20, 2026 •

Copy link
Copy Markdown
Contributor

All changed packages have been documented.

  • ✅ @typespec/http-client-python
Show changes

@typespec/http-client-python - feature ✏️

add support for exact client names

@pkg-pr-new

pkg-pr-new Bot commented May 20, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/@typespec/http-client-python@10750

commit: 577830b

@azure-sdk-automation

azure-sdk-automation Bot commented May 20, 2026 •

Copy link
Copy Markdown

You can try these changes here

🛝 Playground 🌐 Website 🛝 VSCode Extension

@dargilco

Copy link
Copy Markdown
Member

That's awesome! thank you iscai-msft !!!

@tadelesh Chenjie Shi (tadelesh) left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we move the judgement to a helper function and do not repeat in every place?

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 isExactName flag for parameters/properties and use it to choose between exact vs snake_case client naming.
  • Update Python preprocessing/codegen to skip lowercasing/padding when isExactName is set, and avoid consuming the internal stream kwarg when a parameter is exactly named stream.
  • 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.

@iscai-msft
iscai-msft added this pull request to the merge queue May 26, 2026
Merged via the queue into microsoft:main with commit 53f5753 May 26, 2026
41 checks passed
@iscai-msft
iscai-msft deleted the python/addExactSupport branch May 26, 2026 06:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

emitter:client:python Issue for the Python client emitter: @typespec/http-client-python

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants