Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .chronus/changes/fix-model-base-docstrings-2026-7-8-14-9-0.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
changeKind: fix
packages:
- "@typespec/http-client-python"
---

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.`)
Original file line number Diff line number Diff line change
Expand Up @@ -470,21 +470,21 @@ class _MyMutableMapping(MutableMapping[str, typing.Any]):

def keys(self) -> typing.KeysView[str]:
"""
:returns: a set-like object providing a view on D's keys
:returns: a set-like object providing a view on the mapping's keys
:rtype: ~typing.KeysView
"""
return self._data.keys()

def values(self) -> typing.ValuesView[typing.Any]:
"""
:returns: an object providing a view on D's values
:returns: an object providing a view on the mapping's values
:rtype: ~typing.ValuesView
"""
return self._data.values()

def items(self) -> typing.ItemsView[str, typing.Any]:
"""
:returns: set-like object providing a view on D's items
:returns: a set-like object providing a view on the mapping's items
:rtype: ~typing.ItemsView
"""
return self._data.items()
Expand All @@ -494,7 +494,7 @@ class _MyMutableMapping(MutableMapping[str, typing.Any]):
Get the value for key if key is in the dictionary, else default.
:param str key: The key to look up.
:param any default: The value to return if key is not in the dictionary. Defaults to None
:returns: D[k] if k in D, else d.
:returns: The value for key if key is in the dictionary, else default.
:rtype: any
"""
try:
Expand Down Expand Up @@ -529,19 +529,19 @@ class _MyMutableMapping(MutableMapping[str, typing.Any]):
Removes and returns some (key, value) pair
:returns: The (key, value) pair.
:rtype: tuple
:raises KeyError: if D is empty.
:raises KeyError: if the dictionary is empty.
"""
return self._data.popitem()

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

def update(self, *args: typing.Any, **kwargs: typing.Any) -> None: # pylint: disable=arguments-differ
"""
Updates D from mapping/iterable E and F.
Update the dictionary from a mapping or an iterable of key-value pairs.
:param any args: Either a mapping object or an iterable of key-value pairs.
"""
self._data.update(*args, **kwargs)
Expand All @@ -554,10 +554,11 @@ class _MyMutableMapping(MutableMapping[str, typing.Any]):

def setdefault(self, key: str, default: typing.Any = _UNSET) -> typing.Any:
"""
Same as calling D.get(k, d), and setting D[k]=d if k not found
Return the value for key if key is in the dictionary; otherwise set the key to
default and return default.
:param str key: The key to look up.
:param any default: The value to set if key is not in the dictionary
:returns: D[k] if k in D, else d.
:returns: The value for key if key is in the dictionary, else default.
:rtype: any
"""
if default is _UNSET:
Expand Down
Loading