Skip to content

Commit 9d57948

Browse files
committed
[zstd] Improve typing for zstd_dict parameter
1 parent 5d41fd6 commit 9d57948

File tree

4 files changed

+25
-15
lines changed

4 files changed

+25
-15
lines changed

stdlib/_zstd.pyi

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,10 @@ class ZstdCompressor:
4646
FLUSH_BLOCK: Final = 1
4747
FLUSH_FRAME: Final = 2
4848
def __new__(
49-
cls, level: int | None = None, options: Mapping[int, int] | None = None, zstd_dict: ZstdDict | None = None
49+
cls,
50+
level: int | None = None,
51+
options: Mapping[int, int] | None = None,
52+
zstd_dict: ZstdDict | tuple[ZstdDict, int] | None = None,
5053
) -> Self: ...
5154
def compress(
5255
self, /, data: ReadableBuffer, mode: _ZstdCompressorContinue | _ZstdCompressorFlushBlock | _ZstdCompressorFlushFrame = 0
@@ -58,7 +61,9 @@ class ZstdCompressor:
5861

5962
@final
6063
class ZstdDecompressor:
61-
def __new__(cls, zstd_dict: ZstdDict | None = None, options: Mapping[int, int] | None = None) -> Self: ...
64+
def __new__(
65+
cls, zstd_dict: ZstdDict | tuple[ZstdDict, int] | None = None, options: Mapping[int, int] | None = None
66+
) -> Self: ...
6267
def decompress(self, /, data: ReadableBuffer, max_length: int = -1) -> bytes: ...
6368
@property
6469
def eof(self) -> bool: ...

stdlib/compression/zstd/__init__.pyi

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,14 @@ def get_frame_info(frame_buffer: ReadableBuffer) -> FrameInfo: ...
4444
def train_dict(samples: Iterable[ReadableBuffer], dict_size: int) -> ZstdDict: ...
4545
def finalize_dict(zstd_dict: ZstdDict, /, samples: Iterable[ReadableBuffer], dict_size: int, level: int) -> ZstdDict: ...
4646
def compress(
47-
data: ReadableBuffer, level: int | None = None, options: Mapping[int, int] | None = None, zstd_dict: ZstdDict | None = None
47+
data: ReadableBuffer,
48+
level: int | None = None,
49+
options: Mapping[int, int] | None = None,
50+
zstd_dict: ZstdDict | tuple[ZstdDict, int] | None = None,
51+
) -> bytes: ...
52+
def decompress(
53+
data: ReadableBuffer, zstd_dict: ZstdDict | tuple[ZstdDict, int] | None = None, options: Mapping[int, int] | None = None
4854
) -> bytes: ...
49-
def decompress(data: ReadableBuffer, zstd_dict: ZstdDict | None = None, options: Mapping[int, int] | None = None) -> bytes: ...
5055
@final
5156
class CompressionParameter(enum.IntEnum):
5257
compression_level = _zstd.ZSTD_c_compressionLevel

stdlib/compression/zstd/_zstdfile.pyi

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class ZstdFile(_streams.BaseStream):
3636
*,
3737
level: None = None,
3838
options: Mapping[int, int] | None = None,
39-
zstd_dict: ZstdDict | None = None,
39+
zstd_dict: ZstdDict | tuple[ZstdDict, int] | None = None,
4040
) -> None: ...
4141
@overload
4242
def __init__(
@@ -47,7 +47,7 @@ class ZstdFile(_streams.BaseStream):
4747
*,
4848
level: int | None = None,
4949
options: Mapping[int, int] | None = None,
50-
zstd_dict: ZstdDict | None = None,
50+
zstd_dict: ZstdDict | tuple[ZstdDict, int] | None = None,
5151
) -> None: ...
5252
def write(self, data: ReadableBuffer, /) -> int: ...
5353
def flush(self, mode: _ZstdCompressorFlushBlock | _ZstdCompressorFlushFrame = 1) -> bytes: ... # type: ignore[override]
@@ -71,7 +71,7 @@ def open(
7171
*,
7272
level: None = None,
7373
options: Mapping[int, int] | None = None,
74-
zstd_dict: ZstdDict | None = None,
74+
zstd_dict: ZstdDict | tuple[ZstdDict, int] | None = None,
7575
encoding: str | None = None,
7676
errors: str | None = None,
7777
newline: str | None = None,
@@ -84,7 +84,7 @@ def open(
8484
*,
8585
level: int | None = None,
8686
options: Mapping[int, int] | None = None,
87-
zstd_dict: ZstdDict | None = None,
87+
zstd_dict: ZstdDict | tuple[ZstdDict, int] | None = None,
8888
encoding: str | None = None,
8989
errors: str | None = None,
9090
newline: str | None = None,
@@ -97,7 +97,7 @@ def open(
9797
*,
9898
level: None = None,
9999
options: Mapping[int, int] | None = None,
100-
zstd_dict: ZstdDict | None = None,
100+
zstd_dict: ZstdDict | tuple[ZstdDict, int] | None = None,
101101
encoding: str | None = None,
102102
errors: str | None = None,
103103
newline: str | None = None,
@@ -110,7 +110,7 @@ def open(
110110
*,
111111
level: int | None = None,
112112
options: Mapping[int, int] | None = None,
113-
zstd_dict: ZstdDict | None = None,
113+
zstd_dict: ZstdDict | tuple[ZstdDict, int] | None = None,
114114
encoding: str | None = None,
115115
errors: str | None = None,
116116
newline: str | None = None,

stdlib/tarfile.pyi

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ class TarFile:
214214
errorlevel: int | None = ...,
215215
level: None = None,
216216
options: Mapping[int, int] | None = None,
217-
zstd_dict: ZstdDict | None = None,
217+
zstd_dict: ZstdDict | tuple[ZstdDict, int] | None = None,
218218
) -> Self: ...
219219

220220
@overload
@@ -355,7 +355,7 @@ class TarFile:
355355
debug: int | None = ...,
356356
errorlevel: int | None = ...,
357357
options: Mapping[int, int] | None = None,
358-
zstd_dict: ZstdDict | None = None,
358+
zstd_dict: ZstdDict | tuple[ZstdDict, int] | None = None,
359359
) -> Self: ...
360360
@overload
361361
@classmethod
@@ -376,7 +376,7 @@ class TarFile:
376376
debug: int | None = ...,
377377
errorlevel: int | None = ...,
378378
options: Mapping[int, int] | None = None,
379-
zstd_dict: ZstdDict | None = None,
379+
zstd_dict: ZstdDict | tuple[ZstdDict, int] | None = None,
380380
) -> Self: ...
381381

382382
@overload
@@ -611,7 +611,7 @@ class TarFile:
611611
fileobj: IO[bytes] | None = None,
612612
level: None = None,
613613
options: Mapping[int, int] | None = None,
614-
zstd_dict: ZstdDict | None = None,
614+
zstd_dict: ZstdDict | tuple[ZstdDict, int] | None = None,
615615
*,
616616
format: int | None = ...,
617617
tarinfo: type[TarInfo] | None = ...,
@@ -631,7 +631,7 @@ class TarFile:
631631
fileobj: IO[bytes] | None = None,
632632
level: int | None = None,
633633
options: Mapping[int, int] | None = None,
634-
zstd_dict: ZstdDict | None = None,
634+
zstd_dict: ZstdDict | tuple[ZstdDict, int] | None = None,
635635
*,
636636
format: int | None = ...,
637637
tarinfo: type[TarInfo] | None = ...,

0 commit comments

Comments
 (0)