Skip to content

Commit ab94e2b

Browse files
committed
gh-149050: Also fix the Mapping Protocol Access wording
The Mapping Protocol Access bullet about parser.items() in Doc/library/configparser.rst had the same misleading 'returns a list of section_name, section_proxy pairs' phrasing as the items() method description. The no-argument call actually returns an ItemsView, while the call with a section argument returns a list. Mark up both return types explicitly so that the asymmetry between the two overloads is clear to readers.
1 parent 63dd638 commit ab94e2b

1 file changed

Lines changed: 7 additions & 6 deletions

File tree

Doc/library/configparser.rst

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -489,12 +489,13 @@ However, there are a few differences that should be taken into account:
489489
a fallback value. Note however that the section-level ``get()`` methods are
490490
compatible both with the mapping protocol and the classic configparser API.
491491

492-
* ``parser.items()`` is compatible with the mapping protocol (returns a list of
493-
*section_name*, *section_proxy* pairs including the DEFAULTSECT). However,
494-
this method can also be invoked with arguments: ``parser.items(section, raw,
495-
vars)``. The latter call returns a list of *option*, *value* pairs for
496-
a specified ``section``, with all interpolations expanded (unless
497-
``raw=True`` is provided).
492+
* ``parser.items()`` is compatible with the mapping protocol (when invoked
493+
with no arguments, returns an :class:`~collections.abc.ItemsView` of
494+
*section_name*, *section_proxy* pairs including the DEFAULTSECT).
495+
However, this method can also be invoked with arguments:
496+
``parser.items(section, raw, vars)``. The latter call returns a
497+
:class:`list` of *option*, *value* pairs for a specified ``section``,
498+
with all interpolations expanded (unless ``raw=True`` is provided).
498499

499500
The mapping protocol is implemented on top of the existing legacy API so that
500501
subclasses overriding the original interface still should have mappings working

0 commit comments

Comments
 (0)