Skip to content

fix(python): Fix duplicate model docstrings on regeneration#11289

Open
JennyPng wants to merge 4 commits into
microsoft:mainfrom
JennyPng:docstring-bug-fix
Open

fix(python): Fix duplicate model docstrings on regeneration#11289
JennyPng wants to merge 4 commits into
microsoft:mainfrom
JennyPng:docstring-bug-fix

Conversation

@JennyPng

@JennyPng JennyPng commented Jul 17, 2026

Copy link
Copy Markdown
Member

Follow-up fix to #11197 (pylint-guidelines-checker 0.5.9 bump). On regeneration, DPG models emitted a duplicate docstring: :keyword:/:paramtype: lines in the class docstring duplicated the existing :ivar:/:vartype: entries (e.g. InvalidAuth).

Changes

  • Remove the redundant keyword-doc generation for DPG models (the source of the duplicated lines).
  • For DPG models, suppress docstring-keyword-should-match-keyword-only at the class line instead — DPG __init__ overloads have empty bodies, so the checker validates keyword-only args against the class docstring, and we intentionally document those args once as :ivar: entries.

Validation

  • Full regeneration (azure + unbranded) succeeds; docstrings no longer duplicated.

todo

  • disable no-cross-package-private-import in pylintrc of typespec-azure

…s pylint suppressions

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 703c4fd4-5e78-4f26-b389-f4d336687010
@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 Jul 17, 2026
@JennyPng JennyPng changed the title [Python] Fix duplicate model docstrings and useless pylint suppressions fix(python): Fix duplicate model docstrings and useless pylint suppressions Jul 17, 2026
@pkg-pr-new

pkg-pr-new Bot commented Jul 17, 2026

Copy link
Copy Markdown

Open in StackBlitz

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

commit: 0497f9f

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 703c4fd4-5e78-4f26-b389-f4d336687010
@github-actions

github-actions Bot commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

All changed packages have been documented.

  • @typespec/http-client-python
Show changes

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

[Python] Fix duplicate :keyword:/:paramtype: lines in generated DPG model docstrings that duplicated the existing :ivar:/:vartype: entries

@azure-sdk-automation

azure-sdk-automation Bot commented Jul 17, 2026

Copy link
Copy Markdown

You can try these changes here

🛝 Playground 🌐 Website 🛝 VSCode Extension

…string fix

The previous commit removed docstring-missing-param suppressions on
passthrough operations classes and passthrough-only models based on a
tainted local 0.5.9 checker that (incorrectly) exempted (*args, **kwargs)
constructors. The real 0.5.9 used by integration CI still requires those
suppressions, so restore them. The only net change from the base commit
is now: remove the duplicate :keyword:/:paramtype: docstring lines on DPG
models and silence docstring-keyword-should-match-keyword-only instead.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 703c4fd4-5e78-4f26-b389-f4d336687010
@JennyPng JennyPng changed the title fix(python): Fix duplicate model docstrings and useless pylint suppressions fix(python): Fix duplicate model docstrings on regeneration Jul 17, 2026
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 703c4fd4-5e78-4f26-b389-f4d336687010

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

This PR fixes an issue in the Python DPG model generator where regenerated models could end up with duplicated docstring entries (duplicate :keyword:/:paramtype: lines alongside existing :ivar:/:vartype: lines). It removes the redundant keyword-doc generation path and instead suppresses the docstring-keyword-should-match-keyword-only guideline check at the DPG model class declaration line, matching how the guideline checker evaluates empty @overload __init__ bodies.

Changes:

  • Remove rendering of keyword-only :keyword:/:paramtype: docstring lines for DPG models to avoid duplication.
  • Remove the unused keyword_documentation_string serializer helper (verified no remaining references in pygen/).
  • Add a DPG-specific class_pylint_disable override to silence docstring-keyword-should-match-keyword-only when the model has generated keyword-only init parameters.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
packages/http-client-python/generator/pygen/codegen/templates/model_dpg.py.jinja2 Stops emitting per-property :keyword:/:paramtype: lines into the class docstring for DPG models.
packages/http-client-python/generator/pygen/codegen/serializers/model_serializer.py Removes the now-unused keyword-doc helper and adds a DPG class-level pylint disable for the guideline checker rule.
.chronus/changes/python-docstring-duplicate-fix-2026-7-16-22-38-0.md Adds a fix changelog entry for the docstring duplication issue in @typespec/http-client-python.

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.

2 participants