8000 gh-125436: Doc: Add missing ``allow_unnamed_section`` parameter to ``… · python/cpython@d960226 · GitHub
[go: up one dir, main page]

Skip to content

Commit d960226

Browse files
authored
gh-125436: Doc: Add missing allow_unnamed_section parameter to ConfigParser documentation (#125437)
Add missing ``allow_unnamed_section`` parameter to ``ConfigParser`` doc, as well as to it's parent ``RawConfigParser``. Split too long line on ``ConfigParser`` signature. Add some sections about when some of ``RawConfigParser`` parameters were added.
1 parent 7801581 commit d960226

File tree

1 file changed

+28
-3
lines changed

1 file changed

+28
-3
lines changed

Doc/library/configparser.rst

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -942,7 +942,13 @@ interpolation if an option used is not defined elsewhere. ::
942942
ConfigParser Objects
943943
--------------------
944944

945-
.. class:: ConfigParser(defaults=None, dict_type=dict, allow_no_value=False, delimiters=('=', ':'), comment_prefixes=('#', ';'), inline_comment_prefixes=None, strict=True, empty_lines_in_values=True, default_section=configparser.DEFAULTSECT, interpolation=BasicInterpolation(), converters={})
945+
.. class:: ConfigParser(defaults=None, dict_type=dict, allow_no_value=False, *, \
946+
delimiters=('=', ':'), comment_prefixes=('#', ';'), \
947+
inline_comment_prefixes=None, strict=True, \
948+
empty_lines_in_values=True, \
949+
default_section=configparser.DEFAULTSECT, \
950+
interpolation=BasicInterpolation(), converters={}, \
951+
allow_unnamed_section=False)
946952

947953
The main configuration parser. When *defaults* is given, it is initialized
948954
into the dictionary of intrinsic defaults. When *dict_type* is given, it
@@ -990,6 +996,10 @@ ConfigParser Objects
990996
converter gets its own corresponding :meth:`!get*` method on the parser
991997
object and section proxies.
992998

999+
When *allow_unnamed_section* is ``True`` (default: ``False``),
1000+
the first section name can be omitted. See the
1001+
`"Unnamed Sections" section <#unnamed-sections>`_.
1002+
9931003
It is possible to read several configurations into a single
9941004
:class:`ConfigParser`, where the most recently added configuration has the
9951005
highest priority. Any conflicting keys are taken from the more recent
@@ -1039,6 +1049,9 @@ ConfigParser Objects
10391049
Raise a :exc:`MultilineContinuationError` when *allow_no_value* is
10401050
``True``, and a key without a value is continued with an indented line.
10411051

1052+
.. versionchanged:: 3.13
1053+
The *allow_unnamed_section* argument was added.
1054+
10421055
.. method:: defaults()
10431056

10441057
Return a dictionary containing the instance-wide defaults.
@@ -1295,18 +1308,30 @@ RawConfigParser Objects
12951308
comment_prefixes=('#', ';'), \
12961309
inline_comment_prefixes=None, strict=True, \
12971310
empty_lines_in_values=True, \
1298-
default_section=configparser.DEFAULTSECT[, \
1299-
interpolation])
1311+
default_section=configparser.DEFAULTSECT, \
1312+
interpolation=BasicInterpolation(), converters={}, \
1313+
allow_unnamed_section=False)
13001314
13011315
Legacy variant of the :class:`ConfigParser`. It has interpolation
13021316
disabled by default and allows for non-string section names, option
13031317
names, and values via its unsafe ``add_section`` and ``set`` methods,
13041318
as well as the legacy ``defaults=`` keyword argument handling.
13051319

1320+
.. versionchanged:: 3.2
1321+
*allow_no_value*, *delimiters*, *comment_prefixes*, *strict*,
1322+
*empty_lines_in_values*, *default_section* and *interpolation* were
1323+
added.
1324+
1325+
.. versionchanged:: 3.5
1326+
The *converters* argument was added.
1327+
13061328
.. versionchanged:: 3.8
13071329
The default *dict_type* is :class:`dict`, since it now preserves
13081330
insertion order.
13091331

1332+
.. versionchanged:: 3.13
1333+
The *allow_unnamed_section* argument was added.
1334+
13101335
.. note::
13111336
Consider using :class:`ConfigParser` instead which checks types of
13121337
the values to be stored internally. If you don't want interpolation, you

0 commit comments

Comments
 (0)
0