5 from _typeshed import Self, SupportsRead, SupportsWrite
6 from datetime import datetime
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
12 class _SupportsTimeTuple(Protocol):
13 def timetuple(self) -> time.struct_time: ...
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]
20 def escape(s: str) -> str: ... # undocumented
22 MAXINT: int # undocumented
23 MININT: int # undocumented
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
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
39 class Error(Exception): ...
41 class ProtocolError(Error):
46 headers: dict[str, str]
47 def __init__(self, url: str, errcode: int, errmsg: str, headers: dict[str, str]) -> None: ...
49 class ResponseError(Error): ...
55 def __init__(self, faultCode: int, faultString: str, **extra: Any) -> None: ...
60 def _iso8601_format(value: datetime) -> str: ... # undocumented
61 def _strftime(value: _XMLDate) -> str: ... # undocumented
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: ...
77 def _datetime(data: Any) -> DateTime: ... # undocumented
78 def _datetime_type(data: str) -> datetime: ... # undocumented
83 def __init__(self, data: bytes | None = ...) -> None: ...
84 def decode(self, data: bytes) -> None: ...
85 def encode(self, out: SupportsWrite[str]) -> None: ...
87 def _binary(data: bytes) -> Binary: ... # undocumented
89 WRAPPERS: tuple[Type[DateTime], Type[Binary]] # undocumented
91 class ExpatParser: # undocumented
92 def __init__(self, target: Unmarshaller) -> None: ...
93 def feed(self, data: str | bytes) -> None: ...
94 def close(self) -> None: ...
99 Type[Any], Callable[[Marshaller, Any, Callable[[str], Any]], None]
100 ] # TODO: Replace 'Any' with some kind of binding
102 memo: dict[Any, None]
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: ...
118 self, value: Mapping[str, _Marshallable], write: Callable[[str], Any], escape: Callable[[str], str] = ...
120 def dump_datetime(self, value: _XMLDate, write: Callable[[str], Any]) -> None: ...
121 def dump_instance(self, value: object, write: Callable[[str], Any]) -> None: ...
125 dispatch: dict[str, Callable[[Unmarshaller, str], None]]
128 _stack: list[_Marshallable]
132 _methodname: str | None
134 append: Callable[[Any], None]
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: ...
160 class _MultiCallMethod: # undocumented
162 __call_list: list[tuple[str, Tuple[_Marshallable, ...]]]
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: ...
168 class MultiCallIterator: # undocumented
170 results: list[list[_Marshallable]]
171 def __init__(self, results: list[list[_Marshallable]]) -> None: ...
172 def __getitem__(self, i: int) -> _Marshallable: ...
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: ...
183 FastMarshaller: Marshaller | None
184 FastParser: ExpatParser | None
185 FastUnmarshaller: Unmarshaller | None
187 def getparser(use_datetime: bool = ..., use_builtin_types: bool = ...) -> tuple[ExpatParser, Unmarshaller]: ...
189 params: Fault | Tuple[_Marshallable, ...],
190 methodname: str | None = ...,
191 methodresponse: bool | None = ...,
192 encoding: str | None = ...,
193 allow_none: bool = ...,
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
199 class GzipDecodedResponse(gzip.GzipFile): # undocumented
202 def __init__(self, response: SupportsRead[bytes]) -> None: ...
203 def close(self) -> None: ...
205 class _Method: # undocumented
207 __send: Callable[[str, Tuple[_Marshallable, ...]], _Marshallable]
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: ...
216 accept_gzip_encoding: bool
217 encode_threshold: int | None
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]]
225 if sys.version_info >= (3, 8):
227 self, use_datetime: bool = ..., use_builtin_types: bool = ..., *, headers: Iterable[tuple[str, str]] = ...
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, ...]: ...
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, ...]: ...
244 class SafeTransport(Transport):
246 if sys.version_info >= (3, 8):
249 use_datetime: bool = ...,
250 use_builtin_types: bool = ...,
252 headers: Iterable[tuple[str, str]] = ...,
253 context: Any | None = ...,
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: ...
263 __transport: Transport
268 if sys.version_info >= (3, 8):
272 transport: Transport | None = ...,
273 encoding: str | None = ...,
275 allow_none: bool = ...,
276 use_datetime: bool = ...,
277 use_builtin_types: bool = ...,
279 headers: Iterable[tuple[str, str]] = ...,
280 context: Any | None = ...,
286 transport: Transport | None = ...,
287 encoding: str | None = ...,
289 allow_none: bool = ...,
290 use_datetime: bool = ...,
291 use_builtin_types: bool = ...,
293 context: Any | None = ...,
295 def __getattr__(self, name: str) -> _Method: ...
297 def __call__(self, attr: Literal["close"]) -> Callable[[], None]: ...
299 def __call__(self, attr: Literal["transport"]) -> Transport: ...
301 def __call__(self, attr: str) -> Callable[[], None] | Transport: ...
302 def __enter__(self: Self) -> Self: ...
304 self, exc_type: Type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None
306 def __close(self) -> None: ... # undocumented
307 def __request(self, methodname: str, params: Tuple[_Marshallable, ...]) -> Tuple[_Marshallable, ...]: ... # undocumented