Skip to content

Commit 631c992

Browse files
tungolAlexWaygood
andauthored
improve unexposed zlib types (#13032)
Co-authored-by: Alex Waygood <[email protected]>
1 parent 2419d75 commit 631c992

File tree

1 file changed

+22
-8
lines changed

1 file changed

+22
-8
lines changed

stdlib/zlib.pyi

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import sys
22
from _typeshed import ReadableBuffer
3-
from typing import Final
3+
from typing import Any, Final, final, type_check_only
4+
from typing_extensions import Self
45

56
DEFLATED: Final = 8
67
DEF_MEM_LEVEL: int # can change
@@ -27,17 +28,30 @@ Z_TREES: Final = 6
2728

2829
class error(Exception): ...
2930

31+
# This class is not exposed at runtime. It calls itself zlib.Compress.
32+
@final
33+
@type_check_only
3034
class _Compress:
31-
def compress(self, data: ReadableBuffer) -> bytes: ...
32-
def flush(self, mode: int = ...) -> bytes: ...
35+
def __copy__(self) -> Self: ...
36+
def __deepcopy__(self, memo: Any, /) -> Self: ...
37+
def compress(self, data: ReadableBuffer, /) -> bytes: ...
38+
def flush(self, mode: int = 4, /) -> bytes: ...
3339
def copy(self) -> _Compress: ...
3440

41+
# This class is not exposed at runtime. It calls itself zlib.Decompress.
42+
@final
43+
@type_check_only
3544
class _Decompress:
36-
unused_data: bytes
37-
unconsumed_tail: bytes
38-
eof: bool
39-
def decompress(self, data: ReadableBuffer, max_length: int = ...) -> bytes: ...
40-
def flush(self, length: int = ...) -> bytes: ...
45+
@property
46+
def unused_data(self) -> bytes: ...
47+
@property
48+
def unconsumed_tail(self) -> bytes: ...
49+
@property
50+
def eof(self) -> bool: ...
51+
def __copy__(self) -> Self: ...
52+
def __deepcopy__(self, memo: Any, /) -> Self: ...
53+
def decompress(self, data: ReadableBuffer, /, max_length: int = 0) -> bytes: ...
54+
def flush(self, length: int = 16384, /) -> bytes: ...
4155
def copy(self) -> _Decompress: ...
4256

4357
def adler32(data: ReadableBuffer, value: int = 1, /) -> int: ...

0 commit comments

Comments
 (0)