Skip to content

Commit

Permalink
Pickle 5 (#3636)
Browse files Browse the repository at this point in the history
  • Loading branch information
crusaderky authored and srittau committed Jan 23, 2020
1 parent edd1ec8 commit 03c9faa
Showing 1 changed file with 44 additions and 6 deletions.
50 changes: 44 additions & 6 deletions stdlib/2and3/pickle.pyi
Original file line number Diff line number Diff line change
@@ -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: ...
Expand All @@ -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:
Expand All @@ -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:
Expand Down

0 comments on commit 03c9faa

Please sign in to comment.