mirror of
https://github.com/davidhalter/typeshed.git
synced 2026-07-12 03:10:52 +08:00
[compression] Add Protocol _Decompressor (#14885)
This commit is contained in:
+13
-2
@@ -1,6 +1,6 @@
|
||||
# _compression is replaced by compression._common._streams on Python 3.14+ (PEP-784)
|
||||
|
||||
from _typeshed import Incomplete, WriteableBuffer
|
||||
from _typeshed import ReadableBuffer, WriteableBuffer
|
||||
from collections.abc import Callable
|
||||
from io import DEFAULT_BUFFER_SIZE, BufferedIOBase, RawIOBase
|
||||
from typing import Any, Protocol, type_check_only
|
||||
@@ -13,13 +13,24 @@ class _Reader(Protocol):
|
||||
def seekable(self) -> bool: ...
|
||||
def seek(self, n: int, /) -> Any: ...
|
||||
|
||||
@type_check_only
|
||||
class _Decompressor(Protocol):
|
||||
def decompress(self, data: ReadableBuffer, /, max_length: int = ...) -> bytes: ...
|
||||
@property
|
||||
def unused_data(self) -> bytes: ...
|
||||
@property
|
||||
def eof(self) -> bool: ...
|
||||
# `zlib._Decompress` does not have next property, but `DecompressReader` calls it:
|
||||
# @property
|
||||
# def needs_input(self) -> bool: ...
|
||||
|
||||
class BaseStream(BufferedIOBase): ...
|
||||
|
||||
class DecompressReader(RawIOBase):
|
||||
def __init__(
|
||||
self,
|
||||
fp: _Reader,
|
||||
decomp_factory: Callable[..., Incomplete],
|
||||
decomp_factory: Callable[..., _Decompressor],
|
||||
trailing_error: type[Exception] | tuple[type[Exception], ...] = (),
|
||||
**decomp_args: Any, # These are passed to decomp_factory.
|
||||
) -> None: ...
|
||||
|
||||
Reference in New Issue
Block a user