From 1c03574ac49a1fa1ca0c7e8243a91e2fb6b907ff Mon Sep 17 00:00:00 2001 From: Guido van Rossum Date: Thu, 17 Mar 2016 12:57:42 -0700 Subject: [PATCH] Use IO[bytes] instead of BytesIO in the pickle stub. Reason: open() returns IO[Any], which is acceptable as IO[bytes] but not as BytesIO. --- stdlib/3/pickle.pyi | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/stdlib/3/pickle.pyi b/stdlib/3/pickle.pyi index 6d8f51dff..e6a14b2ae 100644 --- a/stdlib/3/pickle.pyi +++ b/stdlib/3/pickle.pyi @@ -1,6 +1,6 @@ # Stubs for pickle -from typing import Any, BinaryIO, Union, Tuple, Callable, Optional, Iterator +from typing import Any, IO, Union, Tuple, Callable, Optional, Iterator # Imports used in type comments only. from typing import Mapping # noqa @@ -8,7 +8,7 @@ HIGHEST_PROTOCOL = ... # type: int DEFAULT_PROTOCOL = ... # type: int -def dump(obj: Any, file: BinaryIO, protocol: int = None, *, +def dump(obj: Any, file: IO[bytes], protocol: int = None, *, fix_imports: bool = ...) -> None: ... @@ -20,7 +20,7 @@ def loads(bytes_object: bytes, *, fix_imports: bool = ..., encoding: str = ..., errors: str = ...) -> Any: ... -def load(file: BinaryIO, *, fix_imports: bool = ..., encoding: str = ..., +def load(file: IO[bytes], *, fix_imports: bool = ..., encoding: str = ..., errors: str = ...) -> Any: ... @@ -48,7 +48,7 @@ _reducedtype = Union[str, class Pickler: dispatch_table = ... # type: Mapping[type, Callable[[Any], _reducedtype]] - def __init__(self, file: BinaryIO, protocol: int = None, *, + def __init__(self, file: IO[bytes], protocol: int = None, *, fix_imports: bool = ...) -> None: ... def dump(self, obj: Any) -> None: ... @@ -57,7 +57,7 @@ class Pickler: class Unpickler: - def __init__(self, file: BinaryIO, *, fix_imports: bool = ..., + def __init__(self, file: IO[bytes], *, fix_imports: bool = ..., encoding: str = ..., errors: str = ...) -> None: ... def load(self) -> Any: ...