Debian Codegraph @

jedi/third_party/typeshed/stdlib/pickle.pyi

raw symbols SCIP
1 import sys
2 from _pickle import (
3 PickleError as PickleError,
4 Pickler as Pickler,
5 PicklingError as PicklingError,
6 Unpickler as Unpickler,
7 UnpicklingError as UnpicklingError,
8 _BufferCallback,
9 _ReadableFileobj,
10 _ReducedType,
11 dump as dump,
12 dumps as dumps,
13 load as load,
14 loads as loads,
15 )
16 from _typeshed import ReadableBuffer, SupportsWrite
17 from collections.abc import Callable, Iterable, Mapping
18 from typing import Any, ClassVar, Final, SupportsBytes, SupportsIndex, final
19 from typing_extensions import Self
20
21 __all__ = [
22 "PickleBuffer",
23 "PickleError",
24 "PicklingError",
25 "UnpicklingError",
26 "Pickler",
27 "Unpickler",
28 "dump",
29 "dumps",
30 "load",
31 "loads",
32 "ADDITEMS",
33 "APPEND",
34 "APPENDS",
35 "BINBYTES",
36 "BINBYTES8",
37 "BINFLOAT",
38 "BINGET",
39 "BININT",
40 "BININT1",
41 "BININT2",
42 "BINPERSID",
43 "BINPUT",
44 "BINSTRING",
45 "BINUNICODE",
46 "BINUNICODE8",
47 "BUILD",
48 "BYTEARRAY8",
49 "DEFAULT_PROTOCOL",
50 "DICT",
51 "DUP",
52 "EMPTY_DICT",
53 "EMPTY_LIST",
54 "EMPTY_SET",
55 "EMPTY_TUPLE",
56 "EXT1",
57 "EXT2",
58 "EXT4",
59 "FALSE",
60 "FLOAT",
61 "FRAME",
62 "FROZENSET",
63 "GET",
64 "GLOBAL",
65 "HIGHEST_PROTOCOL",
66 "INST",
67 "INT",
68 "LIST",
69 "LONG",
70 "LONG1",
71 "LONG4",
72 "LONG_BINGET",
73 "LONG_BINPUT",
74 "MARK",
75 "MEMOIZE",
76 "NEWFALSE",
77 "NEWOBJ",
78 "NEWOBJ_EX",
79 "NEWTRUE",
80 "NEXT_BUFFER",
81 "NONE",
82 "OBJ",
83 "PERSID",
84 "POP",
85 "POP_MARK",
86 "PROTO",
87 "PUT",
88 "READONLY_BUFFER",
89 "REDUCE",
90 "SETITEM",
91 "SETITEMS",
92 "SHORT_BINBYTES",
93 "SHORT_BINSTRING",
94 "SHORT_BINUNICODE",
95 "STACK_GLOBAL",
96 "STOP",
97 "STRING",
98 "TRUE",
99 "TUPLE",
100 "TUPLE1",
101 "TUPLE2",
102 "TUPLE3",
103 "UNICODE",
104 ]
105
106 HIGHEST_PROTOCOL: Final = 5
107 if sys.version_info >= (3, 14):
108 DEFAULT_PROTOCOL: Final = 5
109 else:
110 DEFAULT_PROTOCOL: Final = 4
111
112 bytes_types: tuple[type[Any], ...] # undocumented
113
114 @final
115 class PickleBuffer:
116 def __new__(cls, buffer: ReadableBuffer) -> Self: ...
117 def raw(self) -> memoryview: ...
118 def release(self) -> None: ...
119 def __buffer__(self, flags: int, /) -> memoryview: ...
120 def __release_buffer__(self, buffer: memoryview, /) -> None: ...
121
122 MARK: Final = b"("
123 STOP: Final = b"."
124 POP: Final = b"0"
125 POP_MARK: Final = b"1"
126 DUP: Final = b"2"
127 FLOAT: Final = b"F"
128 INT: Final = b"I"
129 BININT: Final = b"J"
130 BININT1: Final = b"K"
131 LONG: Final = b"L"
132 BININT2: Final = b"M"
133 NONE: Final = b"N"
134 PERSID: Final = b"P"
135 BINPERSID: Final = b"Q"
136 REDUCE: Final = b"R"
137 STRING: Final = b"S"
138 BINSTRING: Final = b"T"
139 SHORT_BINSTRING: Final = b"U"
140 UNICODE: Final = b"V"
141 BINUNICODE: Final = b"X"
142 APPEND: Final = b"a"
143 BUILD: Final = b"b"
144 GLOBAL: Final = b"c"
145 DICT: Final = b"d"
146 EMPTY_DICT: Final = b"}"
147 APPENDS: Final = b"e"
148 GET: Final = b"g"
149 BINGET: Final = b"h"
150 INST: Final = b"i"
151 LONG_BINGET: Final = b"j"
152 LIST: Final = b"l"
153 EMPTY_LIST: Final = b"]"
154 OBJ: Final = b"o"
155 PUT: Final = b"p"
156 BINPUT: Final = b"q"
157 LONG_BINPUT: Final = b"r"
158 SETITEM: Final = b"s"
159 TUPLE: Final = b"t"
160 EMPTY_TUPLE: Final = b")"
161 SETITEMS: Final = b"u"
162 BINFLOAT: Final = b"G"
163
164 TRUE: Final = b"I01\n"
165 FALSE: Final = b"I00\n"
166
167 # protocol 2
168 PROTO: Final = b"\x80"
169 NEWOBJ: Final = b"\x81"
170 EXT1: Final = b"\x82"
171 EXT2: Final = b"\x83"
172 EXT4: Final = b"\x84"
173 TUPLE1: Final = b"\x85"
174 TUPLE2: Final = b"\x86"
175 TUPLE3: Final = b"\x87"
176 NEWTRUE: Final = b"\x88"
177 NEWFALSE: Final = b"\x89"
178 LONG1: Final = b"\x8a"
179 LONG4: Final = b"\x8b"
180
181 # protocol 3
182 BINBYTES: Final = b"B"
183 SHORT_BINBYTES: Final = b"C"
184
185 # protocol 4
186 SHORT_BINUNICODE: Final = b"\x8c"
187 BINUNICODE8: Final = b"\x8d"
188 BINBYTES8: Final = b"\x8e"
189 EMPTY_SET: Final = b"\x8f"
190 ADDITEMS: Final = b"\x90"
191 FROZENSET: Final = b"\x91"
192 NEWOBJ_EX: Final = b"\x92"
193 STACK_GLOBAL: Final = b"\x93"
194 MEMOIZE: Final = b"\x94"
195 FRAME: Final = b"\x95"
196
197 # protocol 5
198 BYTEARRAY8: Final = b"\x96"
199 NEXT_BUFFER: Final = b"\x97"
200 READONLY_BUFFER: Final = b"\x98"
201
202 def encode_long(x: int) -> bytes: ... # undocumented
203 def decode_long(data: Iterable[SupportsIndex] | SupportsBytes | ReadableBuffer) -> int: ... # undocumented
204
205 # undocumented pure-Python implementations
206 class _Pickler:
207 fast: bool
208 dispatch_table: Mapping[type, Callable[[Any], _ReducedType]]
209 bin: bool # undocumented
210 dispatch: ClassVar[dict[type, Callable[[Unpickler, Any], None]]] # undocumented, _Pickler only
211 def __init__(
212 self,
213 file: SupportsWrite[bytes],
214 protocol: int | None = None,
215 *,
216 fix_imports: bool = True,
217 buffer_callback: _BufferCallback = None,
218 ) -> None: ...
219 def dump(self, obj: Any) -> None: ...
220 def clear_memo(self) -> None: ...
221 def persistent_id(self, obj: Any) -> Any: ...
222 # The following method is not defined on _Pickler, but can be defined on
223 # sub-classes. Should return `NotImplemented` if pickling the supplied
224 # object is not supported and returns the same types as `__reduce__()`.
225 def reducer_override(self, obj: object, /) -> _ReducedType: ...
226
227 class _Unpickler:
228 dispatch: ClassVar[dict[int, Callable[[Unpickler], None]]] # undocumented, _Unpickler only
229 def __init__(
230 self,
231 file: _ReadableFileobj,
232 *,
233 fix_imports: bool = True,
234 encoding: str = "ASCII",
235 errors: str = "strict",
236 buffers: Iterable[Any] | None = None,
237 ) -> None: ...
238 def load(self) -> Any: ...
239 def find_class(self, module: str, name: str) -> Any: ...
240 def persistent_load(self, pid: Any) -> Any: ...