Skip to content

fix(http-client-python): clarify _model_base.py mapping docstrings#11216

Merged
msyyc merged 1 commit into
microsoft:mainfrom
l0lawrence:l0lawrence-fix-model-base-docstrings
Jul 9, 2026
Merged

fix(http-client-python): clarify _model_base.py mapping docstrings#11216
msyyc merged 1 commit into
microsoft:mainfrom
l0lawrence:l0lawrence-fix-model-base-docstrings

Conversation

@l0lawrence

Copy link
Copy Markdown
Member

Fixes #11196

Problem

The generated _MyMutableMapping base class in _model_base.py had docstrings using an ambiguous D placeholder (inherited from CPython's MutableMapping ABC), e.g.:

def clear(self) -> None:
    """
    Remove all items from D.
    """

Users couldn't tell what D stood for.

Fix

Updated model_base.py.jinja2 to use plain-English descriptions:

  • clear -> "Remove all items from the dictionary."
  • keys/values/items -> "a view on the mapping's keys/values/items"
  • get / setdefault -> replaced D[k] if k in D, else d with clear wording
  • update -> "Update the dictionary from a mapping or an iterable of key-value pairs."
  • popitem -> "if the dictionary is empty."

The generated test output (tests/generated) is not committed, so no regeneration of committed files was required.

@pkg-pr-new

pkg-pr-new Bot commented Jul 8, 2026

Copy link
Copy Markdown

Open in StackBlitz

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

commit: 875fc93

Comment thread eng/common/scripts/regen-diff/src/render-diff.ts Fixed
Comment thread eng/common/scripts/regen-diff/src/render-diff.ts Fixed
Replace the ambiguous 'D' placeholder (inherited from CPython's
MutableMapping ABC docstrings) in the generated _MyMutableMapping base
class with plain-English descriptions.

Fixes microsoft#11196

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@l0lawrence l0lawrence force-pushed the l0lawrence-fix-model-base-docstrings branch from 6d2ad2b to 875fc93 Compare July 8, 2026 21:26
@microsoft-github-policy-service microsoft-github-policy-service Bot added emitter:client:python Issue for the Python client emitter: @typespec/http-client-python eng labels Jul 8, 2026
@github-actions

github-actions Bot commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

All changed packages have been documented.

  • @typespec/http-client-python
Show changes

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

Clarify docstrings in the generated _MyMutableMapping base class in _model_base.py so they no longer use the ambiguous D placeholder (e.g. Remove all items from D. is now Remove all items from the dictionary.)

@azure-sdk-automation

azure-sdk-automation Bot commented Jul 8, 2026

Copy link
Copy Markdown

You can try these changes here

🛝 Playground 🌐 Website 🛝 VSCode Extension

@l0lawrence

Copy link
Copy Markdown
Member Author

@msyyc msyyc added this pull request to the merge queue Jul 9, 2026
Merged via the queue into microsoft:main with commit 1e6b8a2 Jul 9, 2026
41 of 43 checks passed
tadelesh pushed a commit that referenced this pull request Jul 9, 2026
…11216)

Fixes #11196

## Problem

The generated `_MyMutableMapping` base class in `_model_base.py` had
docstrings using an ambiguous `D` placeholder (inherited from CPython's
`MutableMapping` ABC), e.g.:

```python
def clear(self) -> None:
    """
    Remove all items from D.
    """
```

Users couldn't tell what `D` stood for.

## Fix

Updated `model_base.py.jinja2` to use plain-English descriptions:

- `clear` -> "Remove all items from the dictionary."
- `keys`/`values`/`items` -> "a view on the mapping's keys/values/items"
- `get` / `setdefault` -> replaced `D[k] if k in D, else d` with clear
wording
- `update` -> "Update the dictionary from a mapping or an iterable of
key-value pairs."
- `popitem` -> "if the dictionary is empty."

The generated test output (`tests/generated`) is not committed, so no
regeneration of committed files was required.
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 eng

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Base class in emitted Python code has doc strings like "Remove all items from D"... don't know what "D" stands for

4 participants