Skip to content

Commit 2a5e7d5

Browse files
[3.14] gh-150285: Fix too long docstrings in some Python modules (GH-150366) (GH-150375) (GH-150519)
(cherry picked from commit 01c6d3d) (cherry picked from commit 03244b9) Co-authored-by: Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
1 parent 49975a5 commit 2a5e7d5

11 files changed

Lines changed: 205 additions & 171 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)``.
@@ -927,8 +927,9 @@ def __delitem__(self, key):
927927
__marker = object()
928928

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

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

10311035
def index(self, value, start=0, stop=None):
1032-
'''S.index(value, [start, [stop]]) -> integer -- return first index of value.
1033-
Raises ValueError if the value is not present.
1036+
'''S.index(value, [start, [stop]]) -> integer -- return first index of
1037+
value. Raises ValueError if the value is not present.
10341038
10351039
Supporting start and stop arguments is optional, but
10361040
recommended.
@@ -1138,15 +1142,16 @@ def reverse(self):
11381142
self[i], self[n-i-1] = self[n-i-1], self[i]
11391143

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

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

Lib/enum.py

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -678,26 +678,27 @@ def __call__(cls, value, names=_not_given, *values, module=None, qualname=None,
678678
"""
679679
Either returns an existing member, or creates a new enum class.
680680
681-
This method is used both when an enum class is given a value to match
682-
to an enumeration member (i.e. Color(3)) and for the functional API
683-
(i.e. Color = Enum('Color', names='RED GREEN BLUE')).
681+
This method is used both when an enum class is given a value to
682+
match to an enumeration member (i.e. Color(3)) and for the
683+
functional API (i.e. Color = Enum('Color', names='RED GREEN BLUE')).
684684
685685
The value lookup branch is chosen if the enum is final.
686686
687687
When used for the functional API:
688688
689689
`value` will be the name of the new class.
690690
691-
`names` should be either a string of white-space/comma delimited names
692-
(values will start at `start`), or an iterator/mapping of name, value pairs.
691+
`names` should be either a string of white-space/comma delimited
692+
names (values will start at `start`), or an iterator/mapping of
693+
name, value pairs.
693694
694695
`module` should be set to the module this class is being created in;
695-
if it is not set, an attempt to find that module will be made, but if
696-
it fails the class will not be picklable.
696+
if it is not set, an attempt to find that module will be made, but
697+
if it fails the class will not be picklable.
697698
698-
`qualname` should be set to the actual location this class can be found
699-
at in its module; by default it is set to the global scope. If this is
700-
not correct, unpickling will fail in some circumstances.
699+
`qualname` should be set to the actual location this class can be
700+
found at in its module; by default it is set to the global scope.
701+
If this is not correct, unpickling will fail in some circumstances.
701702
702703
`type`, if set, will be mixed in as the first base class.
703704
"""
@@ -791,8 +792,8 @@ def __members__(cls):
791792
"""
792793
Returns a mapping of member name->value.
793794
794-
This mapping lists all enum members, including aliases. Note that this
795-
is a read-only view of the internal mapping.
795+
This mapping lists all enum members, including aliases. Note that
796+
this is a read-only view of the internal mapping.
796797
"""
797798
return MappingProxyType(cls._member_map_)
798799

Lib/functools.py

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

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.
@@ -294,15 +294,15 @@ def escape(pathname):
294294
def translate(pat, *, recursive=False, include_hidden=False, seps=None):
295295
"""Translate a pathname with shell wildcards to a regular expression.
296296
297-
If `recursive` is true, the pattern segment '**' will match any number of
298-
path segments.
297+
If `recursive` is true, the pattern segment '**' will match any number
298+
of path segments.
299299
300300
If `include_hidden` is true, wildcards can match path segments beginning
301301
with a dot ('.').
302302
303303
If a sequence of separator characters is given to `seps`, they will be
304-
used to split the pattern into segments and match path separators. If not
305-
given, os.path.sep and os.path.altsep (where available) are used.
304+
used to split the pattern into segments and match path separators. If
305+
not given, os.path.sep and os.path.altsep (where available) are used.
306306
"""
307307
if not seps:
308308
if os.path.altsep:

Lib/gzip.py

Lines changed: 32 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -34,16 +34,16 @@ def open(filename, mode="rb", compresslevel=_COMPRESS_LEVEL_BEST,
3434
encoding=None, errors=None, newline=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
@@ -148,8 +148,8 @@ class GzipFile(_streams.BaseStream):
148148
"""The GzipFile class simulates most of the methods of a file object with
149149
the exception of the truncate() method.
150150
151-
This class only supports opening files in binary mode. If you need to open a
152-
compressed file in text mode, use the gzip.open() function.
151+
This class only supports opening files in binary mode. If you need to
152+
open a compressed file in text mode, use the gzip.open() function.
153153
154154
"""
155155

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

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)

Lib/tarfile.py

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -899,19 +899,23 @@ class TarInfo(object):
899899
size = 'Size in bytes.',
900900
mtime = 'Time of last modification.',
901901
chksum = 'Header checksum.',
902-
type = ('File type. type is usually one of these constants: '
903-
'REGTYPE, AREGTYPE, LNKTYPE, SYMTYPE, DIRTYPE, FIFOTYPE, '
904-
'CONTTYPE, CHRTYPE, BLKTYPE, GNUTYPE_SPARSE.'),
902+
type = ('File type. type is usually one of these constants: '
903+
'REGTYPE,\n'
904+
'AREGTYPE, LNKTYPE, SYMTYPE, DIRTYPE, FIFOTYPE, '
905+
'CONTTYPE, CHRTYPE,\n'
906+
'BLKTYPE, GNUTYPE_SPARSE.'),
905907
linkname = ('Name of the target file name, which is only present '
906-
'in TarInfo objects of type LNKTYPE and SYMTYPE.'),
908+
'in TarInfo\n'
909+
'objects of type LNKTYPE and SYMTYPE.'),
907910
uname = 'User name.',
908911
gname = 'Group name.',
909912
devmajor = 'Device major number.',
910913
devminor = 'Device minor number.',
911914
offset = 'The tar header starts here.',
912915
offset_data = "The file's data starts here.",
913916
pax_headers = ('A dictionary containing key-value pairs of an '
914-
'associated pax extended header.'),
917+
'associated pax\n'
918+
'extended header.'),
915919
sparse = 'Sparse member information.',
916920
_tarfile = None,
917921
_sparse_structs = None,
@@ -2273,10 +2277,11 @@ def gettarinfo(self, name=None, arcname=None, fileobj=None):
22732277
return tarinfo
22742278

22752279
def list(self, verbose=True, *, members=None):
2276-
"""Print a table of contents to sys.stdout. If 'verbose' is False, only
2277-
the names of the members are printed. If it is True, an 'ls -l'-like
2278-
output is produced. 'members' is optional and must be a subset of the
2279-
list returned by getmembers().
2280+
"""Print a table of contents to sys.stdout.
2281+
2282+
If 'verbose' is False, only the names of the members are printed.
2283+
If it is True, an 'ls -l'-like output is produced. 'members' is
2284+
optional and must be a subset of the list returned by getmembers().
22802285
"""
22812286
# Convert tarinfo type to stat type.
22822287
type2mode = {REGTYPE: stat.S_IFREG, SYMTYPE: stat.S_IFLNK,
@@ -2367,10 +2372,12 @@ def add(self, name, arcname=None, recursive=True, *, filter=None):
23672372
self.addfile(tarinfo)
23682373

23692374
def addfile(self, tarinfo, fileobj=None):
2370-
"""Add the TarInfo object 'tarinfo' to the archive. If 'tarinfo' represents
2371-
a non zero-size regular file, the 'fileobj' argument should be a binary file,
2372-
and tarinfo.size bytes are read from it and added to the archive.
2373-
You can create TarInfo objects directly, or by using gettarinfo().
2375+
"""Add the TarInfo object 'tarinfo' to the archive.
2376+
2377+
If 'tarinfo' represents a non zero-size regular file, the 'fileobj'
2378+
argument should be a binary file, and tarinfo.size bytes are read
2379+
from it and added to the archive. You can create TarInfo objects
2380+
directly, or by using gettarinfo().
23742381
"""
23752382
self._check("awx")
23762383

0 commit comments

Comments
 (0)