massive update, probably broken
[dotfiles/.git] / .config / coc / extensions / node_modules / coc-pyright / node_modules / pyright / dist / typeshed-fallback / stdlib / xmlrpc / client.pyi
1 import gzip
2 import http.client
3 import sys
4 import time
5 from _typeshed import Self, SupportsRead, SupportsWrite
6 from datetime import datetime
7 from io import BytesIO
8 from types import TracebackType
9 from typing import Any, Callable, Dict, Iterable, List, Mapping, Protocol, Tuple, Type, Union, overload
10 from typing_extensions import Literal
11
12 class _SupportsTimeTuple(Protocol):
13     def timetuple(self) -> time.struct_time: ...
14
15 _DateTimeComparable = Union[DateTime, datetime, str, _SupportsTimeTuple]
16 _Marshallable = Union[None, bool, int, float, str, bytes, Tuple[Any, ...], List[Any], Dict[Any, Any], datetime, DateTime, Binary]
17 _XMLDate = Union[int, datetime, Tuple[int, ...], time.struct_time]
18 _HostType = Union[Tuple[str, Dict[str, str]], str]
19
20 def escape(s: str) -> str: ...  # undocumented
21
22 MAXINT: int  # undocumented
23 MININT: int  # undocumented
24
25 PARSE_ERROR: int  # undocumented
26 SERVER_ERROR: int  # undocumented
27 APPLICATION_ERROR: int  # undocumented
28 SYSTEM_ERROR: int  # undocumented
29 TRANSPORT_ERROR: int  # undocumented
30
31 NOT_WELLFORMED_ERROR: int  # undocumented
32 UNSUPPORTED_ENCODING: int  # undocumented
33 INVALID_ENCODING_CHAR: int  # undocumented
34 INVALID_XMLRPC: int  # undocumented
35 METHOD_NOT_FOUND: int  # undocumented
36 INVALID_METHOD_PARAMS: int  # undocumented
37 INTERNAL_ERROR: int  # undocumented
38
39 class Error(Exception): ...
40
41 class ProtocolError(Error):
42
43     url: str
44     errcode: int
45     errmsg: str
46     headers: dict[str, str]
47     def __init__(self, url: str, errcode: int, errmsg: str, headers: dict[str, str]) -> None: ...
48
49 class ResponseError(Error): ...
50
51 class Fault(Error):
52
53     faultCode: int
54     faultString: str
55     def __init__(self, faultCode: int, faultString: str, **extra: Any) -> None: ...
56
57 boolean = bool
58 Boolean = bool
59
60 def _iso8601_format(value: datetime) -> str: ...  # undocumented
61 def _strftime(value: _XMLDate) -> str: ...  # undocumented
62
63 class DateTime:
64
65     value: str  # undocumented
66     def __init__(self, value: int | str | datetime | time.struct_time | Tuple[int, ...] = ...) -> None: ...
67     def __lt__(self, other: _DateTimeComparable) -> bool: ...
68     def __le__(self, other: _DateTimeComparable) -> bool: ...
69     def __gt__(self, other: _DateTimeComparable) -> bool: ...
70     def __ge__(self, other: _DateTimeComparable) -> bool: ...
71     def __eq__(self, other: _DateTimeComparable) -> bool: ...  # type: ignore
72     def make_comparable(self, other: _DateTimeComparable) -> tuple[str, str]: ...  # undocumented
73     def timetuple(self) -> time.struct_time: ...  # undocumented
74     def decode(self, data: Any) -> None: ...
75     def encode(self, out: SupportsWrite[str]) -> None: ...
76
77 def _datetime(data: Any) -> DateTime: ...  # undocumented
78 def _datetime_type(data: str) -> datetime: ...  # undocumented
79
80 class Binary:
81
82     data: bytes
83     def __init__(self, data: bytes | None = ...) -> None: ...
84     def decode(self, data: bytes) -> None: ...
85     def encode(self, out: SupportsWrite[str]) -> None: ...
86
87 def _binary(data: bytes) -> Binary: ...  # undocumented
88
89 WRAPPERS: tuple[Type[DateTime], Type[Binary]]  # undocumented
90
91 class ExpatParser:  # undocumented
92     def __init__(self, target: Unmarshaller) -> None: ...
93     def feed(self, data: str | bytes) -> None: ...
94     def close(self) -> None: ...
95
96 class Marshaller:
97
98     dispatch: dict[
99         Type[Any], Callable[[Marshaller, Any, Callable[[str], Any]], None]
100     ]  # TODO: Replace 'Any' with some kind of binding
101
102     memo: dict[Any, None]
103     data: None
104     encoding: str | None
105     allow_none: bool
106     def __init__(self, encoding: str | None = ..., allow_none: bool = ...) -> None: ...
107     def dumps(self, values: Fault | Iterable[_Marshallable]) -> str: ...
108     def __dump(self, value: _Marshallable, write: Callable[[str], Any]) -> None: ...  # undocumented
109     def dump_nil(self, value: None, write: Callable[[str], Any]) -> None: ...
110     def dump_bool(self, value: bool, write: Callable[[str], Any]) -> None: ...
111     def dump_long(self, value: int, write: Callable[[str], Any]) -> None: ...
112     def dump_int(self, value: int, write: Callable[[str], Any]) -> None: ...
113     def dump_double(self, value: float, write: Callable[[str], Any]) -> None: ...
114     def dump_unicode(self, value: str, write: Callable[[str], Any], escape: Callable[[str], str] = ...) -> None: ...
115     def dump_bytes(self, value: bytes, write: Callable[[str], Any]) -> None: ...
116     def dump_array(self, value: Iterable[_Marshallable], write: Callable[[str], Any]) -> None: ...
117     def dump_struct(
118         self, value: Mapping[str, _Marshallable], write: Callable[[str], Any], escape: Callable[[str], str] = ...
119     ) -> None: ...
120     def dump_datetime(self, value: _XMLDate, write: Callable[[str], Any]) -> None: ...
121     def dump_instance(self, value: object, write: Callable[[str], Any]) -> None: ...
122
123 class Unmarshaller:
124
125     dispatch: dict[str, Callable[[Unmarshaller, str], None]]
126
127     _type: str | None
128     _stack: list[_Marshallable]
129     _marks: list[int]
130     _data: list[str]
131     _value: bool
132     _methodname: str | None
133     _encoding: str
134     append: Callable[[Any], None]
135     _use_datetime: bool
136     _use_builtin_types: bool
137     def __init__(self, use_datetime: bool = ..., use_builtin_types: bool = ...) -> None: ...
138     def close(self) -> Tuple[_Marshallable, ...]: ...
139     def getmethodname(self) -> str | None: ...
140     def xml(self, encoding: str, standalone: Any) -> None: ...  # Standalone is ignored
141     def start(self, tag: str, attrs: dict[str, str]) -> None: ...
142     def data(self, text: str) -> None: ...
143     def end(self, tag: str) -> None: ...
144     def end_dispatch(self, tag: str, data: str) -> None: ...
145     def end_nil(self, data: str) -> None: ...
146     def end_boolean(self, data: str) -> None: ...
147     def end_int(self, data: str) -> None: ...
148     def end_double(self, data: str) -> None: ...
149     def end_bigdecimal(self, data: str) -> None: ...
150     def end_string(self, data: str) -> None: ...
151     def end_array(self, data: str) -> None: ...
152     def end_struct(self, data: str) -> None: ...
153     def end_base64(self, data: str) -> None: ...
154     def end_dateTime(self, data: str) -> None: ...
155     def end_value(self, data: str) -> None: ...
156     def end_params(self, data: str) -> None: ...
157     def end_fault(self, data: str) -> None: ...
158     def end_methodName(self, data: str) -> None: ...
159
160 class _MultiCallMethod:  # undocumented
161
162     __call_list: list[tuple[str, Tuple[_Marshallable, ...]]]
163     __name: str
164     def __init__(self, call_list: list[tuple[str, _Marshallable]], name: str) -> None: ...
165     def __getattr__(self, name: str) -> _MultiCallMethod: ...
166     def __call__(self, *args: _Marshallable) -> None: ...
167
168 class MultiCallIterator:  # undocumented
169
170     results: list[list[_Marshallable]]
171     def __init__(self, results: list[list[_Marshallable]]) -> None: ...
172     def __getitem__(self, i: int) -> _Marshallable: ...
173
174 class MultiCall:
175
176     __server: ServerProxy
177     __call_list: list[tuple[str, Tuple[_Marshallable, ...]]]
178     def __init__(self, server: ServerProxy) -> None: ...
179     def __getattr__(self, item: str) -> _MultiCallMethod: ...
180     def __call__(self) -> MultiCallIterator: ...
181
182 # A little white lie
183 FastMarshaller: Marshaller | None
184 FastParser: ExpatParser | None
185 FastUnmarshaller: Unmarshaller | None
186
187 def getparser(use_datetime: bool = ..., use_builtin_types: bool = ...) -> tuple[ExpatParser, Unmarshaller]: ...
188 def dumps(
189     params: Fault | Tuple[_Marshallable, ...],
190     methodname: str | None = ...,
191     methodresponse: bool | None = ...,
192     encoding: str | None = ...,
193     allow_none: bool = ...,
194 ) -> str: ...
195 def loads(data: str, use_datetime: bool = ..., use_builtin_types: bool = ...) -> tuple[Tuple[_Marshallable, ...], str | None]: ...
196 def gzip_encode(data: bytes) -> bytes: ...  # undocumented
197 def gzip_decode(data: bytes, max_decode: int = ...) -> bytes: ...  # undocumented
198
199 class GzipDecodedResponse(gzip.GzipFile):  # undocumented
200
201     io: BytesIO
202     def __init__(self, response: SupportsRead[bytes]) -> None: ...
203     def close(self) -> None: ...
204
205 class _Method:  # undocumented
206
207     __send: Callable[[str, Tuple[_Marshallable, ...]], _Marshallable]
208     __name: str
209     def __init__(self, send: Callable[[str, Tuple[_Marshallable, ...]], _Marshallable], name: str) -> None: ...
210     def __getattr__(self, name: str) -> _Method: ...
211     def __call__(self, *args: _Marshallable) -> _Marshallable: ...
212
213 class Transport:
214
215     user_agent: str
216     accept_gzip_encoding: bool
217     encode_threshold: int | None
218
219     _use_datetime: bool
220     _use_builtin_types: bool
221     _connection: tuple[_HostType | None, http.client.HTTPConnection | None]
222     _headers: list[tuple[str, str]]
223     _extra_headers: list[tuple[str, str]]
224
225     if sys.version_info >= (3, 8):
226         def __init__(
227             self, use_datetime: bool = ..., use_builtin_types: bool = ..., *, headers: Iterable[tuple[str, str]] = ...
228         ) -> None: ...
229     else:
230         def __init__(self, use_datetime: bool = ..., use_builtin_types: bool = ...) -> None: ...
231     def request(self, host: _HostType, handler: str, request_body: bytes, verbose: bool = ...) -> Tuple[_Marshallable, ...]: ...
232     def single_request(
233         self, host: _HostType, handler: str, request_body: bytes, verbose: bool = ...
234     ) -> Tuple[_Marshallable, ...]: ...
235     def getparser(self) -> tuple[ExpatParser, Unmarshaller]: ...
236     def get_host_info(self, host: _HostType) -> tuple[str, list[tuple[str, str]], dict[str, str]]: ...
237     def make_connection(self, host: _HostType) -> http.client.HTTPConnection: ...
238     def close(self) -> None: ...
239     def send_request(self, host: _HostType, handler: str, request_body: bytes, debug: bool) -> http.client.HTTPConnection: ...
240     def send_headers(self, connection: http.client.HTTPConnection, headers: list[tuple[str, str]]) -> None: ...
241     def send_content(self, connection: http.client.HTTPConnection, request_body: bytes) -> None: ...
242     def parse_response(self, response: http.client.HTTPResponse) -> Tuple[_Marshallable, ...]: ...
243
244 class SafeTransport(Transport):
245
246     if sys.version_info >= (3, 8):
247         def __init__(
248             self,
249             use_datetime: bool = ...,
250             use_builtin_types: bool = ...,
251             *,
252             headers: Iterable[tuple[str, str]] = ...,
253             context: Any | None = ...,
254         ) -> None: ...
255     else:
256         def __init__(self, use_datetime: bool = ..., use_builtin_types: bool = ..., *, context: Any | None = ...) -> None: ...
257     def make_connection(self, host: _HostType) -> http.client.HTTPSConnection: ...
258
259 class ServerProxy:
260
261     __host: str
262     __handler: str
263     __transport: Transport
264     __encoding: str
265     __verbose: bool
266     __allow_none: bool
267
268     if sys.version_info >= (3, 8):
269         def __init__(
270             self,
271             uri: str,
272             transport: Transport | None = ...,
273             encoding: str | None = ...,
274             verbose: bool = ...,
275             allow_none: bool = ...,
276             use_datetime: bool = ...,
277             use_builtin_types: bool = ...,
278             *,
279             headers: Iterable[tuple[str, str]] = ...,
280             context: Any | None = ...,
281         ) -> None: ...
282     else:
283         def __init__(
284             self,
285             uri: str,
286             transport: Transport | None = ...,
287             encoding: str | None = ...,
288             verbose: bool = ...,
289             allow_none: bool = ...,
290             use_datetime: bool = ...,
291             use_builtin_types: bool = ...,
292             *,
293             context: Any | None = ...,
294         ) -> None: ...
295     def __getattr__(self, name: str) -> _Method: ...
296     @overload
297     def __call__(self, attr: Literal["close"]) -> Callable[[], None]: ...
298     @overload
299     def __call__(self, attr: Literal["transport"]) -> Transport: ...
300     @overload
301     def __call__(self, attr: str) -> Callable[[], None] | Transport: ...
302     def __enter__(self: Self) -> Self: ...
303     def __exit__(
304         self, exc_type: Type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None
305     ) -> None: ...
306     def __close(self) -> None: ...  # undocumented
307     def __request(self, methodname: str, params: Tuple[_Marshallable, ...]) -> Tuple[_Marshallable, ...]: ...  # undocumented
308
309 Server = ServerProxy