Skip to content

Fix Python post-processing scope to preserve user-managed files - #12114

Draft
Libba Lawrence (l0lawrence) wants to merge 1 commit into
microsoft:mainfrom
l0lawrence:l0lawrence-python-post-processing-scope
Draft

Libba Lawrence (l0lawrence) wants to merge 1 commit into
microsoft:mainfrom
l0lawrence:l0lawrence-python-post-processing-scope

Conversation

@l0lawrence

Copy link
Copy Markdown
Member

The Python emitter's post-generation steps currently scan the output directory, formatting and adding pylint suppression comments to pre-existing tests, samples, and other user-managed Python files. This change limits those steps to files written during the current generation.

Approach

  • Record successful writes at the serializer's shared writer layer using normalized absolute paths. Reset tracking on each generation so empty runs and reruns cannot fall back to processing stale files.
  • Use one Python pipeline for native and Pyodide generation, explicitly passing recorded paths to Black formatting and suppression insertion. Batch workers return their paths to the parent for post-processing.
  • Preserve regenerated SDK files, packaging files, generated tests/samples, namespace layouts, and paths outside the immediate generation directory. No public emitter option is added.

This post-generation step does not invoke pylint; it inserts suppression comments where necessary. The standalone pygen.black command now requires explicit filenames. Suppression insertion also preserves stable line endings when extending an existing header.

Validation

  • 63 focused Python regression and adjacent unit tests passed, including byte-for-byte preservation of BOM/CRLF user files, regeneration, empty file sets, threshold boundaries, generated test/sample gating, namespace layouts, the native entry point, and real batch multiprocessing.
  • All 26 emitter tests passed, including native and Node/browser Pyodide routing regressions. Pyodide runtime objects are mocked; the shared Python pipeline is exercised with CPython, not live WASM.
  • TypeScript compilation and generator wheel build passed. Package formatting and emitter lint passed; targeted Python lint, type checks, and whitespace checks passed.

Includes a fix changelog entry and documentation describing the post-processing scope.

Fixes: #11424

Track successful serializer writes and use them for Black formatting and pylint suppressions across native, Pyodide, and batch generation. Preserve user-managed Python files and add regression coverage.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@microsoft-github-policy-service microsoft-github-policy-service Bot added the emitter:client:python Issue for the Python client emitter: @typespec/http-client-python label Oct 5, 2026
@pkg-pr-new

pkg-pr-new Bot commented Oct 5, 2026

Copy link
Copy Markdown

Open in StackBlitz

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

commit: ea6de3f

@azure-sdk-automation

Copy link
Copy Markdown

You can try these changes here

🛝 Playground 🌐 Website 🛝 VSCode Extension

@github-actions

github-actions Bot commented Oct 5, 2026

Copy link
Copy Markdown
Contributor

All changed packages have been documented.

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

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

Limit Black formatting and pylint suppression insertion to Python files written during the current generation, leaving pre-existing user-managed tests, samples, and other Python files unchanged.

@github-actions

github-actions Bot commented Oct 5, 2026

Copy link
Copy Markdown
Contributor

Python emitter diff

Baseline gh:be4c4b7f5646d7eea4affd972d5f69de6c21fdd1 vs this PR.

Diff summary: 1 file(s), +1 / -1

Rendered diff: inline on the run summary, or the emitter-diff-html artifact.

Informational check (eng/emitter-diff); does not block the PR.

This branch has not been deployed

No deployments
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.

[python] pylint runs on tests/ samples/ folders even when not generated by emitter

1 participant