Skip to content

Commit d3e2a13

Browse files
[3.15] gh-150285: Fix too long docstrings in the zstd module (GH-150291) (GH-150335)
(cherry picked from commit 9fceb1c) Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
1 parent e8f534d commit d3e2a13

8 files changed

Lines changed: 140 additions & 136 deletions

File tree

Lib/compression/zstd/__init__.py

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,9 @@ def __setattr__(self, name, _):
6161
def get_frame_info(frame_buffer):
6262
"""Get Zstandard frame information from a frame header.
6363
64-
*frame_buffer* is a bytes-like object. It should start from the beginning
65-
of a frame, and needs to include at least the frame header (6 to 18 bytes).
64+
*frame_buffer* is a bytes-like object. It should start from the
65+
beginning of a frame, and needs to include at least the frame header
66+
(6 to 18 bytes).
6667
6768
The returned FrameInfo object has two attributes.
6869
'decompressed_size' is the size in bytes of the data in the frame when
@@ -103,16 +104,17 @@ def finalize_dict(zstd_dict, /, samples, dict_size, level):
103104
finalize *zstd_dict* by adding headers and statistics according to the
104105
Zstandard dictionary format.
105106
106-
You may compose an effective dictionary content by hand, which is used as
107-
basis dictionary, and use some samples to finalize a dictionary. The basis
108-
dictionary may be a "raw content" dictionary. See *is_raw* in ZstdDict.
107+
You may compose an effective dictionary content by hand, which is used
108+
as basis dictionary, and use some samples to finalize a dictionary. The
109+
basis dictionary may be a "raw content" dictionary. See *is_raw* in
110+
ZstdDict.
109111
110-
*samples* is an iterable of samples, where a sample is a bytes-like object
111-
representing a file.
112+
*samples* is an iterable of samples, where a sample is a bytes-like
113+
object representing a file.
112114
*dict_size* is the dictionary's maximum size, in bytes.
113115
*level* is the expected compression level. The statistics for each
114-
compression level differ, so tuning the dictionary to the compression level
115-
can provide improvements.
116+
compression level differ, so tuning the dictionary to the compression
117+
level can provide improvements.
116118
"""
117119

118120
if not isinstance(zstd_dict, ZstdDict):
@@ -140,8 +142,8 @@ def compress(data, level=None, options=None, zstd_dict=None):
140142
COMPRESSION_LEVEL_DEFAULT ('3').
141143
*options* is a dict object that contains advanced compression
142144
parameters. See CompressionParameter for more on options.
143-
*zstd_dict* is a ZstdDict object, a pre-trained Zstandard dictionary. See
144-
the function train_dict for how to train a ZstdDict on sample data.
145+
*zstd_dict* is a ZstdDict object, a pre-trained Zstandard dictionary.
146+
See the function train_dict for how to train a ZstdDict on sample data.
145147
146148
For incremental compression, use a ZstdCompressor instead.
147149
"""
@@ -152,8 +154,8 @@ def compress(data, level=None, options=None, zstd_dict=None):
152154
def decompress(data, zstd_dict=None, options=None):
153155
"""Decompress one or more frames of Zstandard compressed *data*.
154156
155-
*zstd_dict* is a ZstdDict object, a pre-trained Zstandard dictionary. See
156-
the function train_dict for how to train a ZstdDict on sample data.
157+
*zstd_dict* is a ZstdDict object, a pre-trained Zstandard dictionary.
158+
See the function train_dict for how to train a ZstdDict on sample data.
157159
*options* is a dict object that contains advanced compression
158160
parameters. See DecompressionParameter for more on options.
159161

Lib/compression/zstd/_zstdfile.py

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,9 @@ def __init__(self, file, /, mode='r', *,
3636
3737
*file* can be either an file-like object, or a file name to open.
3838
39-
*mode* can be 'r' for reading (default), 'w' for (over)writing, 'x' for
40-
creating exclusively, or 'a' for appending. These can equivalently be
41-
given as 'rb', 'wb', 'xb' and 'ab' respectively.
39+
*mode* can be 'r' for reading (default), 'w' for (over)writing, 'x'
40+
for creating exclusively, or 'a' for appending. These can
41+
equivalently be given as 'rb', 'wb', 'xb' and 'ab' respectively.
4242
4343
*level* is an optional int specifying the compression level to use,
4444
or COMPRESSION_LEVEL_DEFAULT if not given.
@@ -296,26 +296,27 @@ def open(file, /, mode='rb', *, level=None, options=None, zstd_dict=None,
296296
encoding=None, errors=None, newline=None):
297297
"""Open a Zstandard compressed file in binary or text mode.
298298
299-
file can be either a file name (given as a str, bytes, or PathLike object),
300-
in which case the named file is opened, or it can be an existing file object
301-
to read from or write to.
299+
file can be either a file name (given as a str, bytes, or PathLike
300+
object), in which case the named file is opened, or it can be
301+
an existing file object to read from or write to.
302302
303-
The mode parameter can be 'r', 'rb' (default), 'w', 'wb', 'x', 'xb', 'a',
304-
'ab' for binary mode, or 'rt', 'wt', 'xt', 'at' for text mode.
303+
The mode parameter can be 'r', 'rb' (default), 'w', 'wb', 'x', 'xb',
304+
'a', 'ab' for binary mode, or 'rt', 'wt', 'xt', 'at' for text mode.
305305
306-
The level, options, and zstd_dict parameters specify the settings the same
307-
as ZstdFile.
306+
The level, options, and zstd_dict parameters specify the settings the
307+
same as ZstdFile.
308308
309309
When using read mode (decompression), the options parameter is a dict
310-
representing advanced decompression options. The level parameter is not
311-
supported in this case. When using write mode (compression), only one of
312-
level, an int representing the compression level, or options, a dict
313-
representing advanced compression options, may be passed. In both modes,
314-
zstd_dict is a ZstdDict instance containing a trained Zstandard dictionary.
315-
316-
For binary mode, this function is equivalent to the ZstdFile constructor:
317-
ZstdFile(filename, mode, ...). In this case, the encoding, errors and
318-
newline parameters must not be provided.
310+
representing advanced decompression options. The level parameter is not
311+
supported in this case. When using write mode (compression), only one
312+
of level, an int representing the compression level, or options, a dict
313+
representing advanced compression options, may be passed. In both
314+
modes, zstd_dict is a ZstdDict instance containing a trained Zstandard
315+
dictionary.
316+
317+
For binary mode, this function is equivalent to the ZstdFile
318+
constructor: ZstdFile(filename, mode, ...). In this case, the encoding,
319+
errors and newline parameters must not be provided.
319320
320321
For text mode, an ZstdFile object is created, and wrapped in an
321322
io.TextIOWrapper instance with the specified encoding, error handling

Modules/_zstd/clinic/compressor.c.h

Lines changed: 16 additions & 15 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Modules/_zstd/clinic/decompressor.c.h

Lines changed: 16 additions & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Modules/_zstd/clinic/zstddict.c.h

Lines changed: 16 additions & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)