This commit is contained in:
crusaderky
2020-01-23 18:42:39 +00:00
committed by Sebastian Rittau
parent edd1ec8a62
commit 03c9faa375

View File

@@ -1,20 +1,49 @@
import sys
from typing import Any, IO, Mapping, Union, Tuple, Callable, Optional, Iterator
from typing import Any, IO, Mapping, Union, Tuple, Callable, Optional, Iterable, Iterator
HIGHEST_PROTOCOL: int
if sys.version_info >= (3, 0):
DEFAULT_PROTOCOL: int
if sys.version_info >= (3, 0):
if sys.version_info >= (3, 8):
# TODO: holistic design for buffer interface (typing.Buffer?)
class PickleBuffer:
# buffer must be a buffer-providing object
def __init__(self, buffer: Any) -> None: ...
def raw(self) -> memoryview: ...
def release(self) -> None: ...
_BufferCallback = Optional[Callable[[PickleBuffer], Any]]
def dump(
obj: Any, file: IO[bytes], protocol: Optional[int] = ..., *,
fix_imports: bool = ...,
buffer_callback: _BufferCallback = ...
) -> None: ...
def dumps(
obj: Any, protocol: Optional[int] = ..., *,
fix_imports: bool = ...,
buffer_callback: _BufferCallback = ...
) -> bytes: ...
def load(
file: IO[bytes], *, fix_imports: bool = ..., encoding: str = ...,
errors: str = ..., buffers: Optional[Iterable[Any]] = ...
) -> Any: ...
def loads(
data: bytes, *, fix_imports: bool = ..., encoding: str = ...,
errors: str = ..., buffers: Optional[Iterable[Any]] = ...
) -> Any: ...
elif sys.version_info >= (3, 0):
def dump(obj: Any, file: IO[bytes], protocol: Optional[int] = ..., *,
fix_imports: bool = ...) -> None: ...
def dumps(obj: Any, protocol: Optional[int] = ..., *,
fix_imports: bool = ...) -> bytes: ...
def loads(bytes_object: bytes, *, fix_imports: bool = ...,
encoding: str = ..., errors: str = ...) -> Any: ...
def load(file: IO[bytes], *, fix_imports: bool = ..., encoding: str = ...,
errors: str = ...) -> Any: ...
def loads(data: bytes, *, fix_imports: bool = ...,
encoding: str = ..., errors: str = ...) -> Any: ...
else:
def dump(obj: Any, file: IO[bytes], protocol: Optional[int] = ...) -> None: ...
def dumps(obj: Any, protocol: Optional[int] = ...) -> bytes: ...
@@ -39,7 +68,12 @@ class Pickler:
if sys.version_info >= (3, 3):
dispatch_table: Mapping[type, Callable[[Any], _reducedtype]]
if sys.version_info >= (3, 0):
if sys.version_info >= (3, 8):
def __init__(self, file: IO[bytes], protocol: Optional[int] = ..., *,
fix_imports: bool = ..., buffer_callback: _BufferCallback = ...
) -> None: ...
def reducer_override(self, obj: Any) -> Any: ...
elif sys.version_info >= (3, 0):
def __init__(self, file: IO[bytes], protocol: Optional[int] = ..., *,
fix_imports: bool = ...) -> None: ...
else:
@@ -52,7 +86,11 @@ class Pickler:
def reducer_override(self, obj: Any) -> Any: ...
class Unpickler:
if sys.version_info >= (3, 0):
if sys.version_info >= (3, 8):
def __init__(self, file: IO[bytes], *, fix_imports: bool = ...,
encoding: str = ..., errors: str = ...,
buffers: Optional[Iterable[Any]] = ...) -> None: ...
elif sys.version_info >= (3, 0):
def __init__(self, file: IO[bytes], *, fix_imports: bool = ...,
encoding: str = ..., errors: str = ...) -> None: ...
else: