1
+ from _typeshed import ReadableBuffer
1
2
import sys
2
3
from collections .abc import Callable , Iterable , Iterator , Mapping
3
- from typing import Any , ClassVar , Protocol , Union
4
+ from typing import Any , ClassVar , Protocol , Union , SupportsBytes , SupportsIndex
4
5
from typing_extensions import TypeAlias , final
5
6
6
7
if sys .version_info >= (3 , 8 ):
@@ -183,11 +184,9 @@ class _WritableFileobj(Protocol):
183
184
def write (self , __b : bytes ) -> Any : ...
184
185
185
186
if sys .version_info >= (3 , 8 ):
186
- # TODO: holistic design for buffer interface (typing.Buffer?)
187
187
@final
188
188
class PickleBuffer :
189
- # buffer must be a buffer-providing object
190
- def __init__ (self , buffer : Any ) -> None : ...
189
+ def __init__ (self , buffer : ReadableBuffer ) -> None : ...
191
190
def raw (self ) -> memoryview : ...
192
191
def release (self ) -> None : ...
193
192
_BufferCallback : TypeAlias = Callable [[PickleBuffer ], Any ] | None
@@ -211,14 +210,14 @@ if sys.version_info >= (3, 8):
211
210
buffers : Iterable [Any ] | None = ...,
212
211
) -> Any : ...
213
212
def loads (
214
- __data : bytes , * , fix_imports : bool = ..., encoding : str = ..., errors : str = ..., buffers : Iterable [Any ] | None = ...
213
+ __data : ReadableBuffer , * , fix_imports : bool = ..., encoding : str = ..., errors : str = ..., buffers : Iterable [Any ] | None = ...
215
214
) -> Any : ...
216
215
217
216
else :
218
217
def dump (obj : Any , file : _WritableFileobj , protocol : int | None = ..., * , fix_imports : bool = ...) -> None : ...
219
218
def dumps (obj : Any , protocol : int | None = ..., * , fix_imports : bool = ...) -> bytes : ...
220
219
def load (file : _ReadableFileobj , * , fix_imports : bool = ..., encoding : str = ..., errors : str = ...) -> Any : ...
221
- def loads (data : bytes , * , fix_imports : bool = ..., encoding : str = ..., errors : str = ...) -> Any : ...
220
+ def loads (data : ReadableBuffer , * , fix_imports : bool = ..., encoding : str = ..., errors : str = ...) -> Any : ...
222
221
223
222
class PickleError (Exception ): ...
224
223
class PicklingError (PickleError ): ...
@@ -359,7 +358,7 @@ if sys.version_info >= (3, 8):
359
358
READONLY_BUFFER : bytes
360
359
361
360
def encode_long (x : int ) -> bytes : ... # undocumented
362
- def decode_long (data : bytes ) -> int : ... # undocumented
361
+ def decode_long (data : Iterable [ SupportsIndex ] | SupportsBytes | ReadableBuffer ) -> int : ... # undocumented
363
362
364
363
# pure-Python implementations
365
364
_Pickler = Pickler # undocumented
0 commit comments