Skip to content

Commit c4aeca7

Browse files
committed
gh-150132: Document the no-argument overload of ConfigParser.items()
The docstring of ConfigParser.items() only described the call with a section argument (returning a list of (name, value) tuples). The no-argument call delegates to MutableMapping.items() and returns an ItemsView of (section_name, section_proxy) pairs, which was previously undocumented. Reword the docstring so that both overloads are described and their return types match the actual behaviour.
1 parent 1f3c267 commit c4aeca7

1 file changed

Lines changed: 10 additions & 6 deletions

File tree

Lib/configparser.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -885,13 +885,17 @@ def getboolean(self, section, option, *, raw=False, vars=None,
885885
raw=raw, vars=vars, fallback=fallback, **kwargs)
886886

887887
def items(self, section=_UNSET, raw=False, vars=None):
888-
"""Return a list of (name, value) tuples for each option in a section.
888+
"""Return the items of the parser or of a section.
889889
890-
All % interpolations are expanded in the return values, based on the
891-
defaults passed into the constructor, unless the optional argument
892-
`raw` is true. Additional substitutions may be provided using the
893-
`vars` argument, which must be a dictionary whose contents overrides
894-
any pre-existing defaults.
890+
When `section` is not given, return an ItemsView of
891+
(section_name, section_proxy) pairs, including DEFAULTSECT.
892+
893+
Otherwise, return a list of (name, value) tuples for each option in
894+
the given section. All % interpolations are expanded in the return
895+
values, based on the defaults passed into the constructor, unless the
896+
optional argument `raw` is true. Additional substitutions may be
897+
provided using the `vars` argument, which must be a dictionary whose
898+
contents overrides any pre-existing defaults.
895899
896900
The section DEFAULT is special.
897901
"""

0 commit comments

Comments
 (0)