Skip to content

Commit 18b43cf

Browse files
[3.11] gh-100520: Fix rst markup in configparser docstrings (GH-100524) (#100533)
gh-100520: Fix `rst` markup in `configparser` docstrings (GH-100524) (cherry picked from commit 199507b) Co-authored-by: Nikita Sobolev <mail@sobolevn.me> Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
1 parent 2cb4b13 commit 18b43cf

File tree

1 file changed

+37
-36
lines changed

1 file changed

+37
-36
lines changed

Lib/configparser.py

+37-36
Original file line numberDiff line numberDiff line change
@@ -19,36 +19,37 @@
1919
inline_comment_prefixes=None, strict=True,
2020
empty_lines_in_values=True, default_section='DEFAULT',
2121
interpolation=<unset>, converters=<unset>):
22-
Create the parser. When `defaults' is given, it is initialized into the
22+
23+
Create the parser. When `defaults` is given, it is initialized into the
2324
dictionary or intrinsic defaults. The keys must be strings, the values
2425
must be appropriate for %()s string interpolation.
2526
26-
When `dict_type' is given, it will be used to create the dictionary
27+
When `dict_type` is given, it will be used to create the dictionary
2728
objects for the list of sections, for the options within a section, and
2829
for the default values.
2930
30-
When `delimiters' is given, it will be used as the set of substrings
31+
When `delimiters` is given, it will be used as the set of substrings
3132
that divide keys from values.
3233
33-
When `comment_prefixes' is given, it will be used as the set of
34+
When `comment_prefixes` is given, it will be used as the set of
3435
substrings that prefix comments in empty lines. Comments can be
3536
indented.
3637
37-
When `inline_comment_prefixes' is given, it will be used as the set of
38+
When `inline_comment_prefixes` is given, it will be used as the set of
3839
substrings that prefix comments in non-empty lines.
3940
4041
When `strict` is True, the parser won't allow for any section or option
4142
duplicates while reading from a single source (file, string or
4243
dictionary). Default is True.
4344
44-
When `empty_lines_in_values' is False (default: True), each empty line
45+
When `empty_lines_in_values` is False (default: True), each empty line
4546
marks the end of an option. Otherwise, internal empty lines of
4647
a multiline option are kept as part of the value.
4748
48-
When `allow_no_value' is True (default: False), options without
49+
When `allow_no_value` is True (default: False), options without
4950
values are accepted; the value presented for these is None.
5051
51-
When `default_section' is given, the name of the special section is
52+
When `default_section` is given, the name of the special section is
5253
named accordingly. By default it is called ``"DEFAULT"`` but this can
5354
be customized to point to any other valid section name. Its current
5455
value can be retrieved using the ``parser_instance.default_section``
@@ -87,7 +88,7 @@
8788
read_file(f, filename=None)
8889
Read and parse one configuration file, given as a file object.
8990
The filename defaults to f.name; it is only used in error
90-
messages (if f has no `name' attribute, the string `<???>' is used).
91+
messages (if f has no `name` attribute, the string `<???>` is used).
9192
9293
read_string(string)
9394
Read configuration from a given string.
@@ -103,9 +104,9 @@
103104
Return a string value for the named option. All % interpolations are
104105
expanded in the return values, based on the defaults passed into the
105106
constructor and the DEFAULT section. Additional substitutions may be
106-
provided using the `vars' argument, which must be a dictionary whose
107-
contents override any pre-existing defaults. If `option' is a key in
108-
`vars', the value from `vars' is used.
107+
provided using the `vars` argument, which must be a dictionary whose
108+
contents override any pre-existing defaults. If `option` is a key in
109+
`vars`, the value from `vars` is used.
109110
110111
getint(section, options, raw=False, vars=None, fallback=_UNSET)
111112
Like get(), but convert value to an integer.
@@ -134,7 +135,7 @@
134135
135136
write(fp, space_around_delimiters=True)
136137
Write the configuration state in .ini format. If
137-
`space_around_delimiters' is True (the default), delimiters
138+
`space_around_delimiters` is True (the default), delimiters
138139
between keys and values are surrounded by spaces.
139140
"""
140141

@@ -352,7 +353,7 @@ def __init__(self, filename, lineno, line):
352353

353354

354355
# Used in parser getters to indicate the default behaviour when a specific
355-
# option is not found it to raise an exception. Created to enable `None' as
356+
# option is not found it to raise an exception. Created to enable `None` as
356357
# a valid fallback value.
357358
_UNSET = object()
358359

@@ -386,7 +387,7 @@ class BasicInterpolation(Interpolation):
386387
would resolve the "%(dir)s" to the value of dir. All reference
387388
expansions are done late, on demand. If a user needs to use a bare % in
388389
a configuration file, she can escape it by writing %%. Other % usage
389-
is considered a user error and raises `InterpolationSyntaxError'."""
390+
is considered a user error and raises `InterpolationSyntaxError`."""
390391

391392
_KEYCRE = re.compile(r"%\(([^)]+)\)s")
392393

@@ -447,7 +448,7 @@ def _interpolate_some(self, parser, option, accum, rest, section, map,
447448

448449
class ExtendedInterpolation(Interpolation):
449450
"""Advanced variant of interpolation, supports the syntax used by
450-
`zc.buildout'. Enables interpolation between sections."""
451+
`zc.buildout`. Enables interpolation between sections."""
451452

452453
_KEYCRE = re.compile(r"\$\{([^}]+)\}")
453454

@@ -720,10 +721,10 @@ def read(self, filenames, encoding=None):
720721
def read_file(self, f, source=None):
721722
"""Like read() but the argument must be a file-like object.
722723
723-
The `f' argument must be iterable, returning one line at a time.
724-
Optional second argument is the `source' specifying the name of the
725-
file being read. If not given, it is taken from f.name. If `f' has no
726-
`name' attribute, `<???>' is used.
724+
The `f` argument must be iterable, returning one line at a time.
725+
Optional second argument is the `source` specifying the name of the
726+
file being read. If not given, it is taken from f.name. If `f` has no
727+
`name` attribute, `<???>` is used.
727728
"""
728729
if source is None:
729730
try:
@@ -747,7 +748,7 @@ def read_dict(self, dictionary, source='<dict>'):
747748
All types held in the dictionary are converted to strings during
748749
reading, including section names, option names and keys.
749750
750-
Optional second argument is the `source' specifying the name of the
751+
Optional second argument is the `source` specifying the name of the
751752
dictionary being read.
752753
"""
753754
elements_added = set()
@@ -780,15 +781,15 @@ def readfp(self, fp, filename=None):
780781
def get(self, section, option, *, raw=False, vars=None, fallback=_UNSET):
781782
"""Get an option value for a given section.
782783
783-
If `vars' is provided, it must be a dictionary. The option is looked up
784-
in `vars' (if provided), `section', and in `DEFAULTSECT' in that order.
785-
If the key is not found and `fallback' is provided, it is used as
786-
a fallback value. `None' can be provided as a `fallback' value.
784+
If `vars` is provided, it must be a dictionary. The option is looked up
785+
in `vars` (if provided), `section`, and in `DEFAULTSECT` in that order.
786+
If the key is not found and `fallback` is provided, it is used as
787+
a fallback value. `None` can be provided as a `fallback` value.
787788
788-
If interpolation is enabled and the optional argument `raw' is False,
789+
If interpolation is enabled and the optional argument `raw` is False,
789790
all interpolations are expanded in the return values.
790791
791-
Arguments `raw', `vars', and `fallback' are keyword only.
792+
Arguments `raw`, `vars`, and `fallback` are keyword only.
792793
793794
The section DEFAULT is special.
794795
"""
@@ -848,8 +849,8 @@ def items(self, section=_UNSET, raw=False, vars=None):
848849
849850
All % interpolations are expanded in the return values, based on the
850851
defaults passed into the constructor, unless the optional argument
851-
`raw' is true. Additional substitutions may be provided using the
852-
`vars' argument, which must be a dictionary whose contents overrides
852+
`raw` is true. Additional substitutions may be provided using the
853+
`vars` argument, which must be a dictionary whose contents overrides
853854
any pre-existing defaults.
854855
855856
The section DEFAULT is special.
@@ -891,8 +892,8 @@ def optionxform(self, optionstr):
891892

892893
def has_option(self, section, option):
893894
"""Check for the existence of a given option in a given section.
894-
If the specified `section' is None or an empty string, DEFAULT is
895-
assumed. If the specified `section' does not exist, returns False."""
895+
If the specified `section` is None or an empty string, DEFAULT is
896+
assumed. If the specified `section` does not exist, returns False."""
896897
if not section or section == self.default_section:
897898
option = self.optionxform(option)
898899
return option in self._defaults
@@ -920,7 +921,7 @@ def set(self, section, option, value=None):
920921
def write(self, fp, space_around_delimiters=True):
921922
"""Write an .ini-format representation of the configuration state.
922923
923-
If `space_around_delimiters' is True (the default), delimiters
924+
If `space_around_delimiters` is True (the default), delimiters
924925
between keys and values are surrounded by spaces.
925926
926927
Please note that comments in the original configuration file are not
@@ -938,7 +939,7 @@ def write(self, fp, space_around_delimiters=True):
938939
self._sections[section].items(), d)
939940

940941
def _write_section(self, fp, section_name, section_items, delimiter):
941-
"""Write a single section to the specified `fp'."""
942+
"""Write a single section to the specified `fp`."""
942943
fp.write("[{}]\n".format(section_name))
943944
for key, value in section_items:
944945
value = self._interpolation.before_write(self, section_name, key,
@@ -1012,16 +1013,16 @@ def _read(self, fp, fpname):
10121013
"""Parse a sectioned configuration file.
10131014
10141015
Each section in a configuration file contains a header, indicated by
1015-
a name in square brackets (`[]'), plus key/value options, indicated by
1016-
`name' and `value' delimited with a specific substring (`=' or `:' by
1016+
a name in square brackets (`[]`), plus key/value options, indicated by
1017+
`name` and `value` delimited with a specific substring (`=` or `:` by
10171018
default).
10181019
10191020
Values can span multiple lines, as long as they are indented deeper
10201021
than the first line of the value. Depending on the parser's mode, blank
10211022
lines may be treated as parts of multiline values or ignored.
10221023
10231024
Configuration files may include comments, prefixed by specific
1024-
characters (`#' and `;' by default). Comments may appear on their own
1025+
characters (`#` and `;` by default). Comments may appear on their own
10251026
in an otherwise empty line or may be entered in lines holding values or
10261027
section names. Please note that comments get stripped off when reading configuration files.
10271028
"""

0 commit comments

Comments
 (0)