-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
/
Copy pathpickle.pyi
287 lines (263 loc) · 6.61 KB
/
pickle.pyi
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
import sys
from _typeshed import ReadableBuffer
from collections.abc import Callable, Iterable, Iterator, Mapping
from typing import Any, ClassVar, Protocol, SupportsBytes, Union
from typing_extensions import SupportsIndex, TypeAlias, final
__all__ = [
"PickleError",
"PicklingError",
"UnpicklingError",
"Pickler",
"Unpickler",
"dump",
"dumps",
"load",
"loads",
"ADDITEMS",
"APPEND",
"APPENDS",
"BINBYTES",
"BINBYTES8",
"BINFLOAT",
"BINGET",
"BININT",
"BININT1",
"BININT2",
"BINPERSID",
"BINPUT",
"BINSTRING",
"BINUNICODE",
"BINUNICODE8",
"BUILD",
"DEFAULT_PROTOCOL",
"DICT",
"DUP",
"EMPTY_DICT",
"EMPTY_LIST",
"EMPTY_SET",
"EMPTY_TUPLE",
"EXT1",
"EXT2",
"EXT4",
"FALSE",
"FLOAT",
"FRAME",
"FROZENSET",
"GET",
"GLOBAL",
"HIGHEST_PROTOCOL",
"INST",
"INT",
"LIST",
"LONG",
"LONG1",
"LONG4",
"LONG_BINGET",
"LONG_BINPUT",
"MARK",
"MEMOIZE",
"NEWFALSE",
"NEWOBJ",
"NEWOBJ_EX",
"NEWTRUE",
"NONE",
"OBJ",
"PERSID",
"POP",
"POP_MARK",
"PROTO",
"PUT",
"REDUCE",
"SETITEM",
"SETITEMS",
"SHORT_BINBYTES",
"SHORT_BINSTRING",
"SHORT_BINUNICODE",
"STACK_GLOBAL",
"STOP",
"STRING",
"TRUE",
"TUPLE",
"TUPLE1",
"TUPLE2",
"TUPLE3",
"UNICODE",
]
if sys.version_info >= (3, 8):
__all__ += ["BYTEARRAY8", "NEXT_BUFFER", "PickleBuffer", "READONLY_BUFFER"]
HIGHEST_PROTOCOL: int
DEFAULT_PROTOCOL: int
bytes_types: tuple[type[Any], ...] # undocumented
class _ReadableFileobj(Protocol):
def read(self, __n: int) -> bytes: ...
def readline(self) -> bytes: ...
class _WritableFileobj(Protocol):
def write(self, __b: bytes) -> Any: ...
if sys.version_info >= (3, 8):
@final
class PickleBuffer:
def __init__(self, buffer: ReadableBuffer) -> None: ...
def raw(self) -> memoryview: ...
def release(self) -> None: ...
_BufferCallback: TypeAlias = Callable[[PickleBuffer], Any] | None
def dump(
obj: Any,
file: _WritableFileobj,
protocol: int | None = ...,
*,
fix_imports: bool = ...,
buffer_callback: _BufferCallback = ...,
) -> None: ...
def dumps(
obj: Any, protocol: int | None = ..., *, fix_imports: bool = ..., buffer_callback: _BufferCallback = ...
) -> bytes: ...
def load(
file: _ReadableFileobj,
*,
fix_imports: bool = ...,
encoding: str = ...,
errors: str = ...,
buffers: Iterable[Any] | None = ...,
) -> Any: ...
def loads(
__data: ReadableBuffer,
*,
fix_imports: bool = ...,
encoding: str = ...,
errors: str = ...,
buffers: Iterable[Any] | None = ...,
) -> Any: ...
else:
def dump(obj: Any, file: _WritableFileobj, protocol: int | None = ..., *, fix_imports: bool = ...) -> None: ...
def dumps(obj: Any, protocol: int | None = ..., *, fix_imports: bool = ...) -> bytes: ...
def load(file: _ReadableFileobj, *, fix_imports: bool = ..., encoding: str = ..., errors: str = ...) -> Any: ...
def loads(data: ReadableBuffer, *, fix_imports: bool = ..., encoding: str = ..., errors: str = ...) -> Any: ...
class PickleError(Exception): ...
class PicklingError(PickleError): ...
class UnpicklingError(PickleError): ...
_ReducedType: TypeAlias = Union[
str,
tuple[Callable[..., Any], tuple[Any, ...]],
tuple[Callable[..., Any], tuple[Any, ...], Any],
tuple[Callable[..., Any], tuple[Any, ...], Any, Iterator[Any] | None],
tuple[Callable[..., Any], tuple[Any, ...], Any, Iterator[Any] | None, Iterator[Any] | None],
]
class Pickler:
fast: bool
dispatch_table: Mapping[type, Callable[[Any], _ReducedType]]
bin: bool # undocumented
dispatch: ClassVar[dict[type, Callable[[Unpickler, Any], None]]] # undocumented, _Pickler only
if sys.version_info >= (3, 8):
def __init__(
self,
file: _WritableFileobj,
protocol: int | None = ...,
*,
fix_imports: bool = ...,
buffer_callback: _BufferCallback = ...,
) -> None: ...
def reducer_override(self, obj: Any) -> Any: ...
else:
def __init__(self, file: _WritableFileobj, protocol: int | None = ..., *, fix_imports: bool = ...) -> None: ...
def dump(self, __obj: Any) -> None: ...
def clear_memo(self) -> None: ...
def persistent_id(self, obj: Any) -> Any: ...
class Unpickler:
dispatch: ClassVar[dict[int, Callable[[Unpickler], None]]] # undocumented, _Unpickler only
if sys.version_info >= (3, 8):
def __init__(
self,
file: _ReadableFileobj,
*,
fix_imports: bool = ...,
encoding: str = ...,
errors: str = ...,
buffers: Iterable[Any] | None = ...,
) -> None: ...
else:
def __init__(
self, file: _ReadableFileobj, *, fix_imports: bool = ..., encoding: str = ..., errors: str = ...
) -> None: ...
def load(self) -> Any: ...
def find_class(self, __module_name: str, __global_name: str) -> Any: ...
def persistent_load(self, pid: Any) -> Any: ...
MARK: bytes
STOP: bytes
POP: bytes
POP_MARK: bytes
DUP: bytes
FLOAT: bytes
INT: bytes
BININT: bytes
BININT1: bytes
LONG: bytes
BININT2: bytes
NONE: bytes
PERSID: bytes
BINPERSID: bytes
REDUCE: bytes
STRING: bytes
BINSTRING: bytes
SHORT_BINSTRING: bytes
UNICODE: bytes
BINUNICODE: bytes
APPEND: bytes
BUILD: bytes
GLOBAL: bytes
DICT: bytes
EMPTY_DICT: bytes
APPENDS: bytes
GET: bytes
BINGET: bytes
INST: bytes
LONG_BINGET: bytes
LIST: bytes
EMPTY_LIST: bytes
OBJ: bytes
PUT: bytes
BINPUT: bytes
LONG_BINPUT: bytes
SETITEM: bytes
TUPLE: bytes
EMPTY_TUPLE: bytes
SETITEMS: bytes
BINFLOAT: bytes
TRUE: bytes
FALSE: bytes
# protocol 2
PROTO: bytes
NEWOBJ: bytes
EXT1: bytes
EXT2: bytes
EXT4: bytes
TUPLE1: bytes
TUPLE2: bytes
TUPLE3: bytes
NEWTRUE: bytes
NEWFALSE: bytes
LONG1: bytes
LONG4: bytes
# protocol 3
BINBYTES: bytes
SHORT_BINBYTES: bytes
# protocol 4
SHORT_BINUNICODE: bytes
BINUNICODE8: bytes
BINBYTES8: bytes
EMPTY_SET: bytes
ADDITEMS: bytes
FROZENSET: bytes
NEWOBJ_EX: bytes
STACK_GLOBAL: bytes
MEMOIZE: bytes
FRAME: bytes
if sys.version_info >= (3, 8):
# Protocol 5
BYTEARRAY8: bytes
NEXT_BUFFER: bytes
READONLY_BUFFER: bytes
def encode_long(x: int) -> bytes: ... # undocumented
def decode_long(data: Iterable[SupportsIndex] | SupportsBytes | ReadableBuffer) -> int: ... # undocumented
# pure-Python implementations
_Pickler = Pickler # undocumented
_Unpickler = Unpickler # undocumented