massive update, probably broken
[dotfiles/.git] / .config / coc / extensions / node_modules / coc-pyright / node_modules / pyright / dist / typeshed-fallback / stdlib / pickle.pyi
1 import sys
2 from typing import Any, Callable, ClassVar, Iterable, Iterator, Mapping, Optional, Protocol, Tuple, Type, Union
3 from typing_extensions import final
4
5 HIGHEST_PROTOCOL: int
6 DEFAULT_PROTOCOL: int
7
8 bytes_types: Tuple[Type[Any], ...]  # undocumented
9
10 class _ReadableFileobj(Protocol):
11     def read(self, __n: int) -> bytes: ...
12     def readline(self) -> bytes: ...
13
14 class _WritableFileobj(Protocol):
15     def write(self, __b: bytes) -> Any: ...
16
17 if sys.version_info >= (3, 8):
18     # TODO: holistic design for buffer interface (typing.Buffer?)
19     @final
20     class PickleBuffer:
21         # buffer must be a buffer-providing object
22         def __init__(self, buffer: Any) -> None: ...
23         def raw(self) -> memoryview: ...
24         def release(self) -> None: ...
25     _BufferCallback = Optional[Callable[[PickleBuffer], Any]]
26     def dump(
27         obj: Any,
28         file: _WritableFileobj,
29         protocol: int | None = ...,
30         *,
31         fix_imports: bool = ...,
32         buffer_callback: _BufferCallback = ...,
33     ) -> None: ...
34     def dumps(
35         obj: Any, protocol: int | None = ..., *, fix_imports: bool = ..., buffer_callback: _BufferCallback = ...
36     ) -> bytes: ...
37     def load(
38         file: _ReadableFileobj,
39         *,
40         fix_imports: bool = ...,
41         encoding: str = ...,
42         errors: str = ...,
43         buffers: Iterable[Any] | None = ...,
44     ) -> Any: ...
45     def loads(
46         __data: bytes, *, fix_imports: bool = ..., encoding: str = ..., errors: str = ..., buffers: Iterable[Any] | None = ...
47     ) -> Any: ...
48
49 else:
50     def dump(obj: Any, file: _WritableFileobj, protocol: int | None = ..., *, fix_imports: bool = ...) -> None: ...
51     def dumps(obj: Any, protocol: int | None = ..., *, fix_imports: bool = ...) -> bytes: ...
52     def load(file: _ReadableFileobj, *, fix_imports: bool = ..., encoding: str = ..., errors: str = ...) -> Any: ...
53     def loads(data: bytes, *, fix_imports: bool = ..., encoding: str = ..., errors: str = ...) -> Any: ...
54
55 class PickleError(Exception): ...
56 class PicklingError(PickleError): ...
57 class UnpicklingError(PickleError): ...
58
59 _reducedtype = Union[
60     str,
61     Tuple[Callable[..., Any], Tuple[Any, ...]],
62     Tuple[Callable[..., Any], Tuple[Any, ...], Any],
63     Tuple[Callable[..., Any], Tuple[Any, ...], Any, Optional[Iterator[Any]]],
64     Tuple[Callable[..., Any], Tuple[Any, ...], Any, Optional[Iterator[Any]], Optional[Iterator[Any]]],
65 ]
66
67 class Pickler:
68     fast: bool
69     dispatch_table: Mapping[type, Callable[[Any], _reducedtype]]
70     bin: bool  # undocumented
71     dispatch: ClassVar[dict[type, Callable[[Unpickler, Any], None]]]  # undocumented, _Pickler only
72
73     if sys.version_info >= (3, 8):
74         def __init__(
75             self,
76             file: _WritableFileobj,
77             protocol: int | None = ...,
78             *,
79             fix_imports: bool = ...,
80             buffer_callback: _BufferCallback = ...,
81         ) -> None: ...
82         def reducer_override(self, obj: Any) -> Any: ...
83     else:
84         def __init__(self, file: _WritableFileobj, protocol: int | None = ..., *, fix_imports: bool = ...) -> None: ...
85     def dump(self, __obj: Any) -> None: ...
86     def clear_memo(self) -> None: ...
87     def persistent_id(self, obj: Any) -> Any: ...
88
89 class Unpickler:
90     dispatch: ClassVar[dict[int, Callable[[Unpickler], None]]]  # undocumented, _Unpickler only
91
92     if sys.version_info >= (3, 8):
93         def __init__(
94             self,
95             file: _ReadableFileobj,
96             *,
97             fix_imports: bool = ...,
98             encoding: str = ...,
99             errors: str = ...,
100             buffers: Iterable[Any] | None = ...,
101         ) -> None: ...
102     else:
103         def __init__(
104             self, file: _ReadableFileobj, *, fix_imports: bool = ..., encoding: str = ..., errors: str = ...
105         ) -> None: ...
106     def load(self) -> Any: ...
107     def find_class(self, __module_name: str, __global_name: str) -> Any: ...
108     def persistent_load(self, pid: Any) -> Any: ...
109
110 MARK: bytes
111 STOP: bytes
112 POP: bytes
113 POP_MARK: bytes
114 DUP: bytes
115 FLOAT: bytes
116 INT: bytes
117 BININT: bytes
118 BININT1: bytes
119 LONG: bytes
120 BININT2: bytes
121 NONE: bytes
122 PERSID: bytes
123 BINPERSID: bytes
124 REDUCE: bytes
125 STRING: bytes
126 BINSTRING: bytes
127 SHORT_BINSTRING: bytes
128 UNICODE: bytes
129 BINUNICODE: bytes
130 APPEND: bytes
131 BUILD: bytes
132 GLOBAL: bytes
133 DICT: bytes
134 EMPTY_DICT: bytes
135 APPENDS: bytes
136 GET: bytes
137 BINGET: bytes
138 INST: bytes
139 LONG_BINGET: bytes
140 LIST: bytes
141 EMPTY_LIST: bytes
142 OBJ: bytes
143 PUT: bytes
144 BINPUT: bytes
145 LONG_BINPUT: bytes
146 SETITEM: bytes
147 TUPLE: bytes
148 EMPTY_TUPLE: bytes
149 SETITEMS: bytes
150 BINFLOAT: bytes
151
152 TRUE: bytes
153 FALSE: bytes
154
155 # protocol 2
156 PROTO: bytes
157 NEWOBJ: bytes
158 EXT1: bytes
159 EXT2: bytes
160 EXT4: bytes
161 TUPLE1: bytes
162 TUPLE2: bytes
163 TUPLE3: bytes
164 NEWTRUE: bytes
165 NEWFALSE: bytes
166 LONG1: bytes
167 LONG4: bytes
168
169 # protocol 3
170 BINBYTES: bytes
171 SHORT_BINBYTES: bytes
172
173 # protocol 4
174 SHORT_BINUNICODE: bytes
175 BINUNICODE8: bytes
176 BINBYTES8: bytes
177 EMPTY_SET: bytes
178 ADDITEMS: bytes
179 FROZENSET: bytes
180 NEWOBJ_EX: bytes
181 STACK_GLOBAL: bytes
182 MEMOIZE: bytes
183 FRAME: bytes
184
185 if sys.version_info >= (3, 8):
186     # Protocol 5
187     BYTEARRAY8: bytes
188     NEXT_BUFFER: bytes
189     READONLY_BUFFER: bytes
190
191 def encode_long(x: int) -> bytes: ...  # undocumented
192 def decode_long(data: bytes) -> int: ...  # undocumented
193
194 # pure-Python implementations
195 _Pickler = Pickler  # undocumented
196 _Unpickler = Unpickler  # undocumented