Skip to content

Commit 01c6d3d

Browse files
gh-150285: Fix too long docstrings in some Python modules (GH-150366)
1 parent 7e5d1d8 commit 01c6d3d

12 files changed

Lines changed: 220 additions & 185 deletions

File tree

Lib/_collections_abc.py

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -461,8 +461,8 @@ def __subclasshook__(cls, C):
461461
class _CallableGenericAlias(GenericAlias):
462462
""" Represent `Callable[argtypes, resulttype]`.
463463
464-
This sets ``__args__`` to a tuple containing the flattened ``argtypes``
465-
followed by ``resulttype``.
464+
This sets ``__args__`` to a tuple containing the flattened
465+
``argtypes`` followed by ``resulttype``.
466466
467467
Example: ``Callable[[int, str], float]`` sets ``__args__`` to
468468
``(int, str, float)``.
@@ -928,8 +928,9 @@ def __delitem__(self, key):
928928
__marker = object()
929929

930930
def pop(self, key, default=__marker):
931-
'''D.pop(k[,d]) -> v, remove specified key and return the corresponding value.
932-
If key is not found, d is returned if given, otherwise KeyError is raised.
931+
'''D.pop(k[,d]) -> v, remove specified key and return the corresponding
932+
value. If key is not found, d is returned if given, otherwise
933+
KeyError is raised.
933934
'''
934935
try:
935936
value = self[key]
@@ -963,9 +964,12 @@ def clear(self):
963964

964965
def update(self, other=(), /, **kwds):
965966
''' D.update([E, ]**F) -> None. Update D from mapping/iterable E and F.
966-
If E present and has a .keys() method, does: for k in E.keys(): D[k] = E[k]
967-
If E present and lacks .keys() method, does: for (k, v) in E: D[k] = v
968-
In either case, this is followed by: for k, v in F.items(): D[k] = v
967+
If E present and has a .keys() method, does:
968+
for k in E.keys(): D[k] = E[k]
969+
If E present and lacks .keys() method, does:
970+
for (k, v) in E: D[k] = v
971+
In either case, this is followed by:
972+
for k, v in F.items(): D[k] = v
969973
'''
970974
if isinstance(other, Mapping):
971975
for key in other:
@@ -1030,8 +1034,8 @@ def __reversed__(self):
10301034
yield self[i]
10311035

10321036
def index(self, value, start=0, stop=None):
1033-
'''S.index(value, [start, [stop]]) -> integer -- return first index of value.
1034-
Raises ValueError if the value is not present.
1037+
'''S.index(value, [start, [stop]]) -> integer -- return first index of
1038+
value. Raises ValueError if the value is not present.
10351039
10361040
Supporting start and stop arguments is optional, but
10371041
recommended.
@@ -1139,15 +1143,16 @@ def reverse(self):
11391143
self[i], self[n-i-1] = self[n-i-1], self[i]
11401144

11411145
def extend(self, values):
1142-
'S.extend(iterable) -- extend sequence by appending elements from the iterable'
1146+
"""S.extend(iterable) -- extend sequence by appending elements from the
1147+
iterable"""
11431148
if values is self:
11441149
values = list(values)
11451150
for v in values:
11461151
self.append(v)
11471152

11481153
def pop(self, index=-1):
1149-
'''S.pop([index]) -> item -- remove and return item at index (default last).
1150-
Raise IndexError if list is empty or index is out of range.
1154+
'''S.pop([index]) -> item -- remove and return item at index (default
1155+
last). Raise IndexError if list is empty or index is out of range.
11511156
'''
11521157
v = self[index]
11531158
del self[index]

Lib/enum.py

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -702,26 +702,27 @@ def __call__(cls, value, names=_not_given, *values, module=None, qualname=None,
702702
"""
703703
Either returns an existing member, or creates a new enum class.
704704
705-
This method is used both when an enum class is given a value to match
706-
to an enumeration member (i.e. Color(3)) and for the functional API
707-
(i.e. Color = Enum('Color', names='RED GREEN BLUE')).
705+
This method is used both when an enum class is given a value to
706+
match to an enumeration member (i.e. Color(3)) and for the
707+
functional API (i.e. Color = Enum('Color', names='RED GREEN BLUE')).
708708
709709
The value lookup branch is chosen if the enum is final.
710710
711711
When used for the functional API:
712712
713713
`value` will be the name of the new class.
714714
715-
`names` should be either a string of white-space/comma delimited names
716-
(values will start at `start`), or an iterator/mapping of name, value pairs.
715+
`names` should be either a string of white-space/comma delimited
716+
names (values will start at `start`), or an iterator/mapping of
717+
name, value pairs.
717718
718719
`module` should be set to the module this class is being created in;
719-
if it is not set, an attempt to find that module will be made, but if
720-
it fails the class will not be picklable.
720+
if it is not set, an attempt to find that module will be made, but
721+
if it fails the class will not be picklable.
721722
722-
`qualname` should be set to the actual location this class can be found
723-
at in its module; by default it is set to the global scope. If this is
724-
not correct, unpickling will fail in some circumstances.
723+
`qualname` should be set to the actual location this class can be
724+
found at in its module; by default it is set to the global scope.
725+
If this is not correct, unpickling will fail in some circumstances.
725726
726727
`type`, if set, will be mixed in as the first base class.
727728
"""
@@ -819,8 +820,8 @@ def __members__(cls):
819820
"""
820821
Returns a mapping of member name->value.
821822
822-
This mapping lists all enum members, including aliases. Note that this
823-
is a read-only view of the internal mapping.
823+
This mapping lists all enum members, including aliases. Note that
824+
this is a read-only view of the internal mapping.
824825
"""
825826
return MappingProxyType(cls._member_map_)
826827

Lib/functools.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -563,16 +563,16 @@ def lru_cache(maxsize=128, typed=False):
563563
If *maxsize* is set to None, the LRU features are disabled and the cache
564564
can grow without bound.
565565
566-
If *typed* is True, arguments of different types will be cached separately.
567-
For example, f(decimal.Decimal("3.0")) and f(3.0) will be treated as
568-
distinct calls with distinct results. Some types such as str and int may
569-
be cached separately even when typed is false.
566+
If *typed* is True, arguments of different types will be cached
567+
separately. For example, f(decimal.Decimal("3.0")) and f(3.0) will be
568+
treated as distinct calls with distinct results. Some types such as
569+
str and int may be cached separately even when typed is false.
570570
571571
Arguments to the cached function must be hashable.
572572
573573
View the cache statistics named tuple (hits, misses, maxsize, currsize)
574-
with f.cache_info(). Clear the cache and statistics with f.cache_clear().
575-
Access the underlying function with f.__wrapped__.
574+
with f.cache_info(). Clear the cache and statistics with
575+
f.cache_clear(). Access the underlying function with f.__wrapped__.
576576
577577
See: https://en.wikipedia.org/wiki/Cache_replacement_policies#Least_recently_used_(LRU)
578578

Lib/glob.py

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,17 @@ def glob(pathname, *, root_dir=None, dir_fd=None, recursive=False,
2525
The order of the returned list is undefined. Sort it if you need a
2626
particular order.
2727
28-
If `root_dir` is not None, it should be a path-like object specifying the
29-
root directory for searching. It has the same effect as changing the
30-
current directory before calling it (without actually
31-
changing it). If pathname is relative, the result will contain
32-
paths relative to `root_dir`.
28+
If `root_dir` is not None, it should be a path-like object specifying
29+
the root directory for searching. It has the same effect as changing
30+
the current directory before calling it (without actually changing it).
31+
If pathname is relative, the result will contain paths relative to
32+
`root_dir`.
3333
3434
If `dir_fd` is not None, it should be a file descriptor referring to a
3535
directory, and paths will then be relative to that directory.
3636
37-
If `include_hidden` is true, the patterns '*', '?', '**' will match hidden
38-
directories.
37+
If `include_hidden` is true, the patterns '*', '?', '**' will match
38+
hidden directories.
3939
4040
If `recursive` is true, the pattern '**' will match any files and
4141
zero or more directories and subdirectories.
@@ -56,16 +56,16 @@ def iglob(pathname, *, root_dir=None, dir_fd=None, recursive=False,
5656
particular order.
5757
5858
If `root_dir` is not None, it should be a path-like object specifying
59-
the root directory for searching. It has the same effect as changing
60-
the current directory before calling it (without actually
61-
changing it). If pathname is relative, the result will contain
62-
paths relative to `root_dir`.
59+
the root directory for searching. It has the same effect as changing
60+
the current directory before calling it (without actually changing it).
61+
If pathname is relative, the result will contain paths relative to
62+
`root_dir`.
6363
6464
If `dir_fd` is not None, it should be a file descriptor referring to a
6565
directory, and paths will then be relative to that directory.
6666
67-
If `include_hidden` is true, the patterns '*', '?', '**' will match hidden
68-
directories.
67+
If `include_hidden` is true, the patterns '*', '?', '**' will match
68+
hidden directories.
6969
7070
If `recursive` is true, the pattern '**' will match any files and
7171
zero or more directories and subdirectories.
@@ -279,15 +279,15 @@ def escape(pathname):
279279
def translate(pat, *, recursive=False, include_hidden=False, seps=None):
280280
"""Translate a pathname with shell wildcards to a regular expression.
281281
282-
If `recursive` is true, the pattern segment '**' will match any number of
283-
path segments.
282+
If `recursive` is true, the pattern segment '**' will match any number
283+
of path segments.
284284
285285
If `include_hidden` is true, wildcards can match path segments beginning
286286
with a dot ('.').
287287
288288
If a sequence of separator characters is given to `seps`, they will be
289-
used to split the pattern into segments and match path separators. If not
290-
given, os.path.sep and os.path.altsep (where available) are used.
289+
used to split the pattern into segments and match path separators. If
290+
not given, os.path.sep and os.path.altsep (where available) are used.
291291
"""
292292
if not seps:
293293
if os.path.altsep:

Lib/gzip.py

Lines changed: 33 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -34,16 +34,16 @@ def open(filename, mode="rb", compresslevel=_COMPRESS_LEVEL_TRADEOFF,
3434
encoding=None, errors=None, newline=None, *, mtime=None):
3535
"""Open a gzip-compressed file in binary or text mode.
3636
37-
The filename argument can be an actual filename (a str or bytes object), or
38-
an existing file object to read from or write to.
37+
The filename argument can be an actual filename (a str or bytes object),
38+
or an existing file object to read from or write to.
3939
40-
The mode argument can be "r", "rb", "w", "wb", "x", "xb", "a" or "ab" for
41-
binary mode, or "rt", "wt", "xt" or "at" for text mode. The default mode is
42-
"rb", and the default compresslevel is 9.
40+
The mode argument can be "r", "rb", "w", "wb", "x", "xb", "a" or "ab"
41+
for binary mode, or "rt", "wt", "xt" or "at" for text mode. The default
42+
mode is "rb", and the default compresslevel is 9.
4343
44-
For binary mode, this function is equivalent to the GzipFile constructor:
45-
GzipFile(filename, mode, compresslevel). In this case, the encoding, errors
46-
and newline arguments must not be provided.
44+
For binary mode, this function is equivalent to the GzipFile
45+
constructor: GzipFile(filename, mode, compresslevel). In this case,
46+
the encoding, errors and newline arguments must not be provided.
4747
4848
For text mode, a GzipFile object is created, and wrapped in an
4949
io.TextIOWrapper instance with the specified encoding, error handling
@@ -149,8 +149,8 @@ class GzipFile(_streams.BaseStream):
149149
"""The GzipFile class simulates most of the methods of a file object with
150150
the exception of the truncate() method.
151151
152-
This class only supports opening files in binary mode. If you need to open a
153-
compressed file in text mode, use the gzip.open() function.
152+
This class only supports opening files in binary mode. If you need to
153+
open a compressed file in text mode, use the gzip.open() function.
154154
155155
"""
156156

@@ -166,33 +166,34 @@ def __init__(self, filename=None, mode=None,
166166
non-trivial value.
167167
168168
The new class instance is based on fileobj, which can be a regular
169-
file, an io.BytesIO object, or any other object which simulates a file.
170-
It defaults to None, in which case filename is opened to provide
171-
a file object.
169+
file, an io.BytesIO object, or any other object which simulates
170+
a file. It defaults to None, in which case filename is opened to
171+
provide a file object.
172172
173173
When fileobj is not None, the filename argument is only used to be
174174
included in the gzip file header, which may include the original
175175
filename of the uncompressed file. It defaults to the filename of
176176
fileobj, if discernible; otherwise, it defaults to the empty string,
177-
and in this case the original filename is not included in the header.
178-
179-
The mode argument can be any of 'r', 'rb', 'a', 'ab', 'w', 'wb', 'x', or
180-
'xb' depending on whether the file will be read or written. The default
181-
is the mode of fileobj if discernible; otherwise, the default is 'rb'.
182-
A mode of 'r' is equivalent to one of 'rb', and similarly for 'w' and
183-
'wb', 'a' and 'ab', and 'x' and 'xb'.
184-
185-
The compresslevel argument is an integer from 0 to 9 controlling the
186-
level of compression; 1 is fastest and produces the least compression,
187-
and 9 is slowest and produces the most compression. 0 is no compression
188-
at all. The default is 9.
189-
190-
The optional mtime argument is the timestamp requested by gzip. The time
191-
is in Unix format, i.e., seconds since 00:00:00 UTC, January 1, 1970.
192-
Set mtime to 0 to generate a compressed stream that does not depend on
193-
creation time. If mtime is omitted or None, the current time is used.
194-
If the resulting mtime is outside the range 0 to 2**32-1, then the
195-
value 0 is used instead.
177+
and in this case the original filename is not included in the
178+
header.
179+
180+
The mode argument can be any of 'r', 'rb', 'a', 'ab', 'w', 'wb',
181+
'x', or 'xb' depending on whether the file will be read or written.
182+
The default is the mode of fileobj if discernible; otherwise, the
183+
default is 'rb'. A mode of 'r' is equivalent to one of 'rb', and
184+
similarly for 'w' and 'wb', 'a' and 'ab', and 'x' and 'xb'.
185+
186+
The compresslevel argument is an integer from 0 to 9 controlling
187+
the level of compression; 1 is fastest and produces the least
188+
compression, and 9 is slowest and produces the most compression.
189+
0 is no compression at all. The default is 9.
190+
191+
The optional mtime argument is the timestamp requested by gzip.
192+
The time is in Unix format, i.e., seconds since 00:00:00 UTC,
193+
January 1, 1970. Set mtime to 0 to generate a compressed stream
194+
that does not depend on creation time. If mtime is omitted or None,
195+
the current time is used. If the resulting mtime is outside the
196+
range 0 to 2**32-1, then the value 0 is used instead.
196197
197198
"""
198199

Lib/json/__init__.py

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -292,12 +292,13 @@ def load(fp, *, cls=None, object_hook=None, parse_float=None,
292292
``object_hook`` is also defined, the ``object_pairs_hook`` takes
293293
priority.
294294
295-
``array_hook`` is an optional function that will be called with the result
296-
of any literal array decode (a ``list``). The return value of this function will
297-
be used instead of the ``list``. This feature can be used along
298-
``object_pairs_hook`` to customize the resulting data structure - for example,
299-
by setting that to ``frozendict`` and ``array_hook`` to ``tuple``, one can get
300-
a deep immutable data structute from any JSON data.
295+
``array_hook`` is an optional function that will be called with the
296+
result of any literal array decode (a ``list``). The return value of
297+
this function will be used instead of the ``list``. This feature can
298+
be used along ``object_pairs_hook`` to customize the resulting data
299+
structure - for example, by setting that to ``frozendict`` and
300+
``array_hook`` to ``tuple``, one can get a deep immutable data structure
301+
from any JSON data.
301302
302303
To use a custom ``JSONDecoder`` subclass, specify it with the ``cls``
303304
kwarg; otherwise ``JSONDecoder`` is used.
@@ -327,12 +328,13 @@ def loads(s, *, cls=None, object_hook=None, parse_float=None,
327328
``object_hook`` is also defined, the ``object_pairs_hook`` takes
328329
priority.
329330
330-
``array_hook`` is an optional function that will be called with the result
331-
of any literal array decode (a ``list``). The return value of this function will
332-
be used instead of the ``list``. This feature can be used along
333-
``object_pairs_hook`` to customize the resulting data structure - for example,
334-
by setting that to ``frozendict`` and ``array_hook`` to ``tuple``, one can get
335-
a deep immutable data structute from any JSON data.
331+
``array_hook`` is an optional function that will be called with the
332+
result of any literal array decode (a ``list``). The return value of
333+
this function will be used instead of the ``list``. This feature can
334+
be used along ``object_pairs_hook`` to customize the resulting data
335+
structure - for example, by setting that to ``frozendict`` and
336+
``array_hook`` to ``tuple``, one can get a deep immutable data structure
337+
from any JSON data.
336338
337339
``parse_float``, if specified, will be called with the string
338340
of every JSON float to be decoded. By default this is equivalent to

Lib/ntpath.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -152,12 +152,14 @@ def splitdrive(p, /):
152152
It is always true that:
153153
result[0] + result[1] == p
154154
155-
If the path contained a drive letter, drive_or_unc will contain everything
156-
up to and including the colon. e.g. splitdrive("c:/dir") returns ("c:", "/dir")
155+
If the path contained a drive letter, drive_or_unc will contain
156+
everything up to and including the colon. e.g. splitdrive("c:/dir")
157+
returns ("c:", "/dir")
157158
158-
If the path contained a UNC path, the drive_or_unc will contain the host name
159-
and share up to but not including the fourth directory separator character.
160-
e.g. splitdrive("//host/computer/dir") returns ("//host/computer", "/dir")
159+
If the path contained a UNC path, the drive_or_unc will contain the
160+
host name and share up to but not including the fourth directory
161+
separator character. e.g. splitdrive("//host/computer/dir") returns
162+
("//host/computer", "/dir")
161163
162164
Paths cannot contain both a drive letter and a UNC path.
163165
@@ -222,8 +224,8 @@ def splitroot(p, /):
222224
def split(p, /):
223225
"""Split a pathname.
224226
225-
Return tuple (head, tail) where tail is everything after the final slash.
226-
Either part may be empty."""
227+
Return tuple (head, tail) where tail is everything after the final
228+
slash. Either part may be empty."""
227229
p = os.fspath(p)
228230
seps = _get_bothseps(p)
229231
d, r, p = splitroot(p)

0 commit comments

Comments
 (0)