From 06f9ddb56700d777afd216c05b82eb94c4e20394 Mon Sep 17 00:00:00 2001 From: Viicos <65306057+Viicos@users.noreply.github.com> Date: Fri, 11 Oct 2024 09:03:19 +0200 Subject: [PATCH] Apply feedback and update docstring of `MutableMapping.update` --- Doc/library/stdtypes.rst | 22 +++++++++---------- Lib/_collections_abc.py | 2 +- ...-10-09-21-41-36.gh-issue-116938.ChLcRx.rst | 2 -- 3 files changed, 12 insertions(+), 14 deletions(-) delete mode 100644 Misc/NEWS.d/next/Documentation/2024-10-09-21-41-36.gh-issue-116938.ChLcRx.rst diff --git a/Doc/library/stdtypes.rst b/Doc/library/stdtypes.rst index 20d54da52d847b..b39359aef9e465 100644 --- a/Doc/library/stdtypes.rst +++ b/Doc/library/stdtypes.rst @@ -4506,13 +4506,13 @@ can be used interchangeably to index the same dictionary entry. If no positional argument is given, an empty dictionary is created. If a positional argument is given and it defines a ``keys()`` method, a - dictionary is created by calling ``__getitem__`` on the argument with each - returned key from the method. Otherwise, the positional argument must be an + dictionary is created by calling :meth:`~object.__getitem__` on the argument with + each returned key from the method. Otherwise, the positional argument must be an :term:`iterable` object. Each item in the iterable must itself be an iterable - with exactly two objects. The first object of each item becomes a key in the new - dictionary, and the second object the corresponding value. If a key occurs more - than once, the last value for that key becomes the corresponding value in the new - dictionary. + with exactly two objects. The first element of each item becomes a key in the + new dictionary, and the second element the corresponding value. If a key occurs + more than once, the last value for that key becomes the corresponding value in + the new dictionary. If keyword arguments are given, the keyword arguments and their values are added to the dictionary created from the positional argument. If a key @@ -4669,11 +4669,11 @@ can be used interchangeably to index the same dictionary entry. Update the dictionary with the key/value pairs from *other*, overwriting existing keys. Return ``None``. - :meth:`update` accepts either another object with a ``keys()`` method - (in which case ``__getitem__`` is called with every key returned from the method). - or an iterable of key/value pairs (as tuples or other iterables of length two). - If keyword arguments are specified, the dictionary is then updated with those - key/value pairs: ``d.update(red=1, blue=2)``. + :meth:`update` accepts either another object with a ``keys()`` method (in + which case :meth:`~object.__getitem__` is called with every key returned from + the method). or an iterable of key/value pairs (as tuples or other iterables + of length two). If keyword arguments are specified, the dictionary is then + updated with those key/value pairs: ``d.update(red=1, blue=2)``. .. method:: values() diff --git a/Lib/_collections_abc.py b/Lib/_collections_abc.py index c2edf6c8856c21..06667b7434ccef 100644 --- a/Lib/_collections_abc.py +++ b/Lib/_collections_abc.py @@ -962,7 +962,7 @@ def clear(self): def update(self, other=(), /, **kwds): ''' D.update([E, ]**F) -> None. Update D from mapping/iterable E and F. - If E present and has a .keys() method, does: for k in E: D[k] = E[k] + If E present and has a .keys() method, does: for k in E.keys(): D[k] = E[k] If E present and lacks .keys() method, does: for (k, v) in E: D[k] = v In either case, this is followed by: for k, v in F.items(): D[k] = v ''' diff --git a/Misc/NEWS.d/next/Documentation/2024-10-09-21-41-36.gh-issue-116938.ChLcRx.rst b/Misc/NEWS.d/next/Documentation/2024-10-09-21-41-36.gh-issue-116938.ChLcRx.rst deleted file mode 100644 index fc8175357c87f5..00000000000000 --- a/Misc/NEWS.d/next/Documentation/2024-10-09-21-41-36.gh-issue-116938.ChLcRx.rst +++ /dev/null @@ -1,2 +0,0 @@ -Clarify documentation of :class:`dict` and :meth:`dict.update` regarding the -positional argument they accept.