mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-07 12:44:28 +08:00
Make pickle accept IO[str] instead of BinaryIO. (#980)
* Make pickle accept IO[str] instead of BinaryIO. This makes the following code work: pickle.Unpickler(cStringIO.StringIO()) (Which didn't work before because cStringIO.StringIO inherits "only" from IO[str], not BinaryIO) * Use bytes instead of str.
This commit is contained in:
@@ -1,14 +1,14 @@
|
||||
# Stubs for pickle (Python 2)
|
||||
|
||||
from typing import Any, BinaryIO
|
||||
from typing import Any, IO
|
||||
|
||||
|
||||
HIGHEST_PROTOCOL = ... # type: int
|
||||
|
||||
|
||||
def dump(obj: Any, file: BinaryIO, protocol: int = None) -> None: ...
|
||||
def dump(obj: Any, file: IO[bytes], protocol: int = None) -> None: ...
|
||||
def dumps(obj: Any, protocol: int = ...) -> bytes: ...
|
||||
def load(file: BinaryIO) -> Any: ...
|
||||
def load(file: IO[bytes]) -> Any: ...
|
||||
def loads(string: bytes) -> Any: ...
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ class UnpicklingError(PickleError):
|
||||
|
||||
|
||||
class Pickler:
|
||||
def __init__(self, file: BinaryIO, protocol: int = None) -> None: ...
|
||||
def __init__(self, file: IO[bytes], protocol: int = None) -> None: ...
|
||||
|
||||
def dump(self, obj: Any) -> None: ...
|
||||
|
||||
@@ -33,6 +33,6 @@ class Pickler:
|
||||
|
||||
|
||||
class Unpickler:
|
||||
def __init__(self, file: BinaryIO) -> None: ...
|
||||
def __init__(self, file: IO[bytes]) -> None: ...
|
||||
|
||||
def load(self) -> Any: ...
|
||||
|
||||
Reference in New Issue
Block a user