Skip to content

fix(http-client-python): prevent Pylint statement-limit errors for SSE operations - #12281

Merged
Libba Lawrence (l0lawrence) merged 1 commit into
microsoft:mainfrom
l0lawrence:fix-python-sse-pylint
Oct 15, 2026
Merged

Libba Lawrence (l0lawrence) merged 1 commit into
microsoft:mainfrom
l0lawrence:fix-python-sse-pylint

Conversation

@l0lawrence

@l0lawrence Libba Lawrence (l0lawrence) commented Oct 15, 2026 •

Copy link
Copy Markdown
Member

Summary

Search SDK regeneration reported Pylint too-many-statements (54/50) on both synchronous and asynchronous retrieve_stream implementations.

  • Emit a method-scoped too-many-statements suppression for non-overload structured-stream implementations, following existing generator conventions.
  • Leave overload declarations, non-structured-stream operations, runtime behavior, and global lint limits unchanged.
  • Add targeted regression coverage and a Chronus fix entry for @typespec/http-client-python.

The separate Search wrapper typed-event/bytes incompatibility is not included.

Validation

  • Python emitter npm run build passed.
  • Python emitter npm run format and npm run lint -- --emitter passed.
  • Repository pnpm format passed.
  • 271 related Python unit tests passed, including sync/async, reconnect, JSONL, and overload cases.
  • Regression tests render the production operation template and reproduce 54/50 statements (65/50 with reconnect) when the directive is removed; generated output passes the statement-limit check with the fix.
  • Touched generator source passed Pylint; regression tests passed Black formatting checks.

Actual downstream Search regeneration

Regenerated azure-search-documents from committed SDK snapshot cb86c24d343eb1eee5c86d39c4b135eebe6bf110, preserving spec pin c195a3fe73b28cd90bf8a302944b2c0ec3d80def and API version 2026-08-01-preview. Used wrapper @azure-tools/typespec-python 0.63.10, this PR's locally packed @typespec/http-client-python 0.39.0, compiler 1.17.0, and TCGC 0.73.0 with native generation through tsp-client 0.33.1. All 15 handwritten patch files remained unchanged; existing generation workarounds were reapplied.

  • Full Search namespace Pylint passed using Pylint 4.0.4 and repository-pinned Azure guidelines checker 0.5.7.
  • Exact negative control: removing only the two generated method-level suppression comments produced exactly two R0915 errors, both 54/50, with no other full-package Pylint failures.
  • Sync and async implementations have the suppression; all three overload declarations for each remain unsuppressed. The two SSE operation files differ from prior regenerated outputs only by these two comments.
  • Unit tests: 184 passed.
  • Recorded/playback tests: 342 passed, 2 failed. Both failures are the separate existing sync/async Search wrapper incompatibility: TypeError: can't concat KnowledgeBaseRetrievalStartedEvent to bytes. No wrapper or test changes were made. This confirms the lint fix, not full Search runtime compatibility.
  • Black: 78 source files passed.
  • Sphinx and MyPy were not rerun for this downstream validation.

Dependencies were restored exclusively through CFS without manifest or lockfile changes; no Pyodide fallback was used. The tarball source, installed npm source, bundled generator wheel, and freshly reinstalled generator source were verified identical for operation.py. Validated emitter artifact SHA256: b2091bcb9c52de989d118e4569afd666e777a27535266bf69db765311143bf3c.

… streams

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

pkg-pr-new Bot commented Oct 15, 2026

Copy link
Copy Markdown

Open in StackBlitz

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

commit: 2d33aa0

@github-actions

Copy link
Copy Markdown
Contributor

All changed packages have been documented.

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

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

Prevent Pylint too-many-statements errors in generated synchronous and asynchronous structured-stream operations with SSE event dispatch. Scope the suppression to operation implementations, leaving overload declarations and non-structured-stream operations unchanged.

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.

🟡 Changes recommended

Short operations can produce unused-suppression diagnostics, and the isolated unit-test environment lacks Pylint.

2 open findings
What changed in this PR

Updates the Python client generator to suppress statement-limit warnings for structured-stream implementations without changing runtime behavior.

Changes:

  • Adds method-scoped suppression, excluding overload declarations.
  • Adds sync/async regression coverage and a Chronus fix entry.
File Description
packages/​http-client-python/​tests/​unit/​test_structured_stream_pylint.py Tests suppression scope and generated SSE lint results.
packages/​http-client-python/​generator/​pygen/​codegen/​models/​operation.py Adds structured-stream statement-limit suppression.
.chronus/​changes/​http-client-python-sse-pylint-2026-10-14.md Documents the generator fix.

🧠 Review effort: Balanced


💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@github-actions

Copy link
Copy Markdown
Contributor

Python emitter diff

Baseline gh:cb772cb5e11bb63b021e8854533adf08dd62f587 vs this PR.

Diff summary: 28 file(s), +156 / -84

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

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

@azure-sdk-automation

azure-sdk-automation Bot commented Oct 15, 2026 •

Copy link
Copy Markdown

You can try these changes here

🛝 Playground 🌐 Website 🛝 VSCode Extension

@l0lawrence
Libba Lawrence (l0lawrence) added this pull request to the merge queue Oct 15, 2026
Merged via the queue into microsoft:main with commit 9d202fa Oct 15, 2026
37 checks passed
@l0lawrence
Libba Lawrence (l0lawrence) deleted the fix-python-sse-pylint branch October 15, 2026 18:22
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.

3 participants