apply black and isort (#4287)

* apply black and isort

* move some type ignores
This commit is contained in:
Jelle Zijlstra
2020-06-28 13:31:00 -07:00
committed by GitHub
parent fe58699ca5
commit 5d553c9584
800 changed files with 13875 additions and 10332 deletions

View File

@@ -1,17 +1,19 @@
import gzip
import http.client
import io
import sys
import time
import gzip
import http.client
from typing import Any, Callable, Dict, Iterable, List, Mapping, Optional, Protocol, Tuple, Type, Union, overload
from typing_extensions import Literal
from types import TracebackType
from datetime import datetime
from types import TracebackType
from typing import Any, Callable, Dict, Iterable, List, Mapping, Optional, Protocol, Tuple, Type, Union, overload
from typing_extensions import Literal
from _typeshed import SupportsRead, SupportsWrite
class _SupportsTimeTuple(Protocol):
def timetuple(self) -> time.struct_time: ...
_DateTimeComparable = Union[DateTime, datetime, str, _SupportsTimeTuple]
_Marshallable = Union[None, bool, int, float, str, bytes, tuple, list, dict, datetime, DateTime, Binary]
_XMLDate = Union[int, datetime, Tuple[int, ...], time.struct_time]
@@ -41,7 +43,6 @@ class ProtocolError(Error):
errcode: int
errmsg: str
headers: Dict[str, str]
def __init__(self, url: str, errcode: int, errmsg: str, headers: Dict[str, str]) -> None: ...
class ResponseError(Error): ...
@@ -50,10 +51,8 @@ class Fault(Error):
faultCode: str
faultString: str
def __init__(self, faultCode: str, faultString: str, **extra: Any) -> None: ...
boolean = bool
Boolean = bool
@@ -63,7 +62,6 @@ def _strftime(value: _XMLDate) -> str: ... # undocumented
class DateTime:
value: str # undocumented
def __init__(self, value: Union[int, str, datetime, time.struct_time, Tuple[int, ...]] = ...): ...
def __lt__(self, other: _DateTimeComparable) -> bool: ...
def __le__(self, other: _DateTimeComparable) -> bool: ...
@@ -81,7 +79,6 @@ def _datetime_type(data: str) -> datetime: ... # undocumented
class Binary:
data: bytes
def __init__(self, data: Optional[bytes] = ...) -> None: ...
def decode(self, data: bytes) -> None: ...
def encode(self, out: SupportsWrite[str]) -> None: ...
@@ -91,20 +88,20 @@ def _binary(data: bytes) -> Binary: ... # undocumented
WRAPPERS: Tuple[Type[DateTime], Type[Binary]] # undocumented
class ExpatParser: # undocumented
def __init__(self, target: Unmarshaller) -> None: ...
def feed(self, data: Union[str, bytes]) -> None: ...
def close(self) -> None: ...
class Marshaller:
dispatch: Dict[Type[Any], Callable[[Marshaller, Any, Callable[[str], Any]], None]] = ... # TODO: Replace 'Any' with some kind of binding
dispatch: Dict[
Type[Any], Callable[[Marshaller, Any, Callable[[str], Any]], None]
] = ... # TODO: Replace 'Any' with some kind of binding
memo: Dict[Any, None]
data: None
encoding: Optional[str]
allow_none: bool
def __init__(self, encoding: Optional[str] = ..., allow_none: bool = ...) -> None: ...
def dumps(self, values: Union[Fault, Iterable[_Marshallable]]) -> str: ...
def __dump(self, value: Union[_Marshallable], write: Callable[[str], Any]) -> None: ... # undocumented
@@ -116,7 +113,9 @@ class Marshaller:
def dump_unicode(self, value: str, write: Callable[[str], Any], escape: Callable[[str], str] = ...) -> None: ...
def dump_bytes(self, value: bytes, write: Callable[[str], Any]) -> None: ...
def dump_array(self, value: Iterable[_Marshallable], write: Callable[[str], Any]) -> None: ...
def dump_struct(self, value: Mapping[str, _Marshallable], write: Callable[[str], Any], escape: Callable[[str], str] = ...) -> None: ...
def dump_struct(
self, value: Mapping[str, _Marshallable], write: Callable[[str], Any], escape: Callable[[str], str] = ...
) -> None: ...
def dump_datetime(self, value: _XMLDate, write: Callable[[str], Any]) -> None: ...
def dump_instance(self, value: object, write: Callable[[str], Any]) -> None: ...
@@ -134,7 +133,6 @@ class Unmarshaller:
append: Callable[[Any], None]
_use_datetime: bool
_use_builtin_types: bool
def __init__(self, use_datetime: bool = ..., use_builtin_types: bool = ...) -> None: ...
def close(self) -> Tuple[_Marshallable, ...]: ...
def getmethodname(self) -> Optional[str]: ...
@@ -163,7 +161,6 @@ class _MultiCallMethod: # undocumented
__call_list: List[Tuple[str, Tuple[_Marshallable, ...]]]
__name: str
def __init__(self, call_list: List[Tuple[str, _Marshallable]], name: str) -> None: ...
def __getattr__(self, name: str) -> _MultiCallMethod: ...
def __call__(self, *args: _Marshallable) -> None: ...
@@ -171,7 +168,6 @@ class _MultiCallMethod: # undocumented
class MultiCallIterator: # undocumented
results: List[List[_Marshallable]]
def __init__(self, results: List[List[_Marshallable]]) -> None: ...
def __getitem__(self, i: int) -> _Marshallable: ...
@@ -179,7 +175,6 @@ class MultiCall:
__server: ServerProxy
__call_list: List[Tuple[str, Tuple[_Marshallable, ...]]]
def __init__(self, server: ServerProxy) -> None: ...
def __getattr__(self, item: str) -> _MultiCallMethod: ...
def __call__(self) -> MultiCallIterator: ...
@@ -190,16 +185,22 @@ FastParser: Optional[ExpatParser]
FastUnmarshaller: Optional[Unmarshaller]
def getparser(use_datetime: bool = ..., use_builtin_types: bool = ...) -> Tuple[ExpatParser, Unmarshaller]: ...
def dumps(params: Union[Fault, Tuple[_Marshallable, ...]], methodname: Optional[str] = ..., methodresponse: Optional[bool] = ..., encoding: Optional[str] = ..., allow_none: bool = ...) -> str: ...
def loads(data: str, use_datetime: bool = ..., use_builtin_types: bool = ...) -> Tuple[Tuple[_Marshallable, ...], Optional[str]]: ...
def dumps(
params: Union[Fault, Tuple[_Marshallable, ...]],
methodname: Optional[str] = ...,
methodresponse: Optional[bool] = ...,
encoding: Optional[str] = ...,
allow_none: bool = ...,
) -> str: ...
def loads(
data: str, use_datetime: bool = ..., use_builtin_types: bool = ...
) -> Tuple[Tuple[_Marshallable, ...], Optional[str]]: ...
def gzip_encode(data: bytes) -> bytes: ... # undocumented
def gzip_decode(data: bytes, max_decode: int = ...) -> bytes: ... # undocumented
class GzipDecodedResponse(gzip.GzipFile): # undocumented
io: io.BytesIO
def __init__(self, response: SupportsRead[bytes]) -> None: ...
def close(self) -> None: ...
@@ -207,7 +208,6 @@ class _Method: # undocumented
__send: Callable[[str, Tuple[_Marshallable, ...]], _Marshallable]
__name: str
def __init__(self, send: Callable[[str, Tuple[_Marshallable, ...]], _Marshallable], name: str) -> None: ...
def __getattr__(self, name: str) -> _Method: ...
def __call__(self, *args: _Marshallable) -> _Marshallable: ...
@@ -225,11 +225,15 @@ class Transport:
_extra_headers: List[Tuple[str, str]]
if sys.version_info >= (3, 8):
def __init__(self, use_datetime: bool = ..., use_builtin_types: bool = ..., *, headers: Iterable[Tuple[str, str]] = ...) -> None: ...
def __init__(
self, use_datetime: bool = ..., use_builtin_types: bool = ..., *, headers: Iterable[Tuple[str, str]] = ...
) -> None: ...
else:
def __init__(self, use_datetime: bool = ..., use_builtin_types: bool = ...) -> None: ...
def request(self, host: _HostType, handler: str, request_body: bytes, verbose: bool = ...) -> Tuple[_Marshallable, ...]: ...
def single_request(self, host: _HostType, handler: str, request_body: bytes, verbose: bool = ...) -> Tuple[_Marshallable, ...]: ...
def single_request(
self, host: _HostType, handler: str, request_body: bytes, verbose: bool = ...
) -> Tuple[_Marshallable, ...]: ...
def getparser(self) -> Tuple[ExpatParser, Unmarshaller]: ...
def get_host_info(self, host: _HostType) -> Tuple[str, List[Tuple[str, str]], Dict[str, str]]: ...
def make_connection(self, host: _HostType) -> http.client.HTTPConnection: ...
@@ -242,7 +246,14 @@ class Transport:
class SafeTransport(Transport):
if sys.version_info >= (3, 8):
def __init__(self, use_datetime: bool = ..., use_builtin_types: bool = ..., *, headers: Iterable[Tuple[str, str]] = ..., context: Optional[Any] = ...) -> None: ...
def __init__(
self,
use_datetime: bool = ...,
use_builtin_types: bool = ...,
*,
headers: Iterable[Tuple[str, str]] = ...,
context: Optional[Any] = ...,
) -> None: ...
else:
def __init__(self, use_datetime: bool = ..., use_builtin_types: bool = ..., *, context: Optional[Any] = ...) -> None: ...
def make_connection(self, host: _HostType) -> http.client.HTTPSConnection: ...
@@ -257,9 +268,32 @@ class ServerProxy:
__allow_none: bool
if sys.version_info >= (3, 8):
def __init__(self, uri, transport: Optional[Transport] = ..., encoding: Optional[str] = ..., verbose: bool = ..., allow_none: bool = ..., use_datetime: bool = ..., use_builtin_types: bool = ..., *, headers: Iterable[Tuple[str, str]] = ..., context: Optional[Any] = ...) -> None: ...
def __init__(
self,
uri,
transport: Optional[Transport] = ...,
encoding: Optional[str] = ...,
verbose: bool = ...,
allow_none: bool = ...,
use_datetime: bool = ...,
use_builtin_types: bool = ...,
*,
headers: Iterable[Tuple[str, str]] = ...,
context: Optional[Any] = ...,
) -> None: ...
else:
def __init__(self, uri, transport: Optional[Transport] = ..., encoding: Optional[str] = ..., verbose: bool = ..., allow_none: bool = ..., use_datetime: bool = ..., use_builtin_types: bool = ..., *, context: Optional[Any] = ...) -> None: ...
def __init__(
self,
uri,
transport: Optional[Transport] = ...,
encoding: Optional[str] = ...,
verbose: bool = ...,
allow_none: bool = ...,
use_datetime: bool = ...,
use_builtin_types: bool = ...,
*,
context: Optional[Any] = ...,
) -> None: ...
def __getattr__(self, name: str) -> _Method: ...
@overload
def __call__(self, attr: Literal["close"]) -> Callable[[], None]: ...
@@ -268,7 +302,9 @@ class ServerProxy:
@overload
def __call__(self, attr: str) -> Union[Callable[[], None], Transport]: ...
def __enter__(self) -> ServerProxy: ...
def __exit__(self, exc_type: Optional[Type[BaseException]], exc_val: Optional[BaseException], exc_tb: Optional[TracebackType]) -> None: ...
def __exit__(
self, exc_type: Optional[Type[BaseException]], exc_val: Optional[BaseException], exc_tb: Optional[TracebackType]
) -> None: ...
def __close(self) -> None: ... # undocumented
def __request(self, methodname: str, params: Tuple[_Marshallable, ...]) -> Tuple[_Marshallable, ...]: ... # undocumented

View File

@@ -1,29 +1,37 @@
import http.server
import socketserver
import pydoc
import socketserver
import sys
from xmlrpc.client import Fault
from typing import Any, Callable, Dict, Iterable, List, Mapping, Optional, Pattern, Protocol, Tuple, Type, Union
from datetime import datetime
from typing import Any, Callable, Dict, Iterable, List, Mapping, Optional, Pattern, Protocol, Tuple, Type, Union
from xmlrpc.client import Fault
_Marshallable = Union[None, bool, int, float, str, bytes, tuple, list, dict, datetime] # TODO: Recursive type on tuple, list, dict
_Marshallable = Union[
None, bool, int, float, str, bytes, tuple, list, dict, datetime
] # TODO: Recursive type on tuple, list, dict
# The dispatch accepts anywhere from 0 to N arguments, no easy way to allow this in mypy
class _DispatchArity0(Protocol):
def __call__(self) -> _Marshallable: ...
class _DispatchArity1(Protocol):
def __call__(self, __arg1: _Marshallable) -> _Marshallable: ...
class _DispatchArity2(Protocol):
def __call__(self, __arg1: _Marshallable, __arg2: _Marshallable) -> _Marshallable: ...
class _DispatchArity3(Protocol):
def __call__(self, __arg1: _Marshallable, __arg2: _Marshallable, __arg3: _Marshallable) -> _Marshallable: ...
class _DispatchArity4(Protocol):
def __call__(self, __arg1: _Marshallable, __arg2: _Marshallable, __arg3: _Marshallable, __arg4: _Marshallable) -> _Marshallable: ...
def __call__(
self, __arg1: _Marshallable, __arg2: _Marshallable, __arg3: _Marshallable, __arg4: _Marshallable
) -> _Marshallable: ...
class _DispatchArityN(Protocol):
def __call__(self, *args: _Marshallable) -> _Marshallable: ...
_DispatchProtocol = Union[_DispatchArity0, _DispatchArity1, _DispatchArity2, _DispatchArity3, _DispatchArity4, _DispatchArityN]
_DispatchProtocol = Union[_DispatchArity0, _DispatchArity1, _DispatchArity2, _DispatchArity3, _DispatchArity4, _DispatchArityN]
def resolve_dotted_attribute(obj: Any, attr: str, allow_dotted_names: bool = ...) -> Any: ... # undocumented
def list_public_methods(obj: Any) -> List[str]: ... # undocumented
@@ -35,16 +43,24 @@ class SimpleXMLRPCDispatcher: # undocumented
allow_none: bool
encoding: str
use_builtin_types: bool
def __init__(self, allow_none: bool = ..., encoding: Optional[str] = ..., use_builtin_types: bool = ...) -> None: ...
def register_instance(self, instance: Any, allow_dotted_names: bool = ...) -> None: ...
if sys.version_info >= (3, 7):
def register_function(self, function: Optional[_DispatchProtocol] = ..., name: Optional[str] = ...) -> Callable[..., Any]: ...
def register_function(
self, function: Optional[_DispatchProtocol] = ..., name: Optional[str] = ...
) -> Callable[..., Any]: ...
else:
def register_function(self, function: _DispatchProtocol, name: Optional[str] = ...) -> Callable[..., Any]: ...
def register_introspection_functions(self) -> None: ...
def register_multicall_functions(self) -> None: ...
def _marshaled_dispatch(self, data: str, dispatch_method: Optional[Callable[[Optional[str], Tuple[_Marshallable, ...]], Union[Fault, Tuple[_Marshallable, ...]]]] = ..., path: Optional[Any] = ...) -> str: ... # undocumented
def _marshaled_dispatch(
self,
data: str,
dispatch_method: Optional[
Callable[[Optional[str], Tuple[_Marshallable, ...]], Union[Fault, Tuple[_Marshallable, ...]]]
] = ...,
path: Optional[Any] = ...,
) -> str: ... # undocumented
def system_listMethods(self) -> List[str]: ... # undocumented
def system_methodSignature(self, method_name: str) -> str: ... # undocumented
def system_methodHelp(self, method_name: str) -> str: ... # undocumented
@@ -56,7 +72,6 @@ class SimpleXMLRPCRequestHandler(http.server.BaseHTTPRequestHandler):
rpc_paths: Tuple[str, str] = ...
encode_threshold: int = ... # undocumented
aepattern: Pattern[str] # undocumented
def accept_encodings(self) -> Dict[str, float]: ...
def is_rpc_path_valid(self) -> bool: ...
def do_POST(self) -> None: ...
@@ -68,29 +83,50 @@ class SimpleXMLRPCServer(socketserver.TCPServer, SimpleXMLRPCDispatcher):
allow_reuse_address: bool = ...
_send_traceback_handler: bool = ...
def __init__(self, addr: Tuple[str, int], requestHandler: Type[SimpleXMLRPCRequestHandler] = ..., logRequests: bool = ..., allow_none: bool = ..., encoding: Optional[str] = ..., bind_and_activate: bool = ..., use_builtin_types: bool = ...) -> None: ...
def __init__(
self,
addr: Tuple[str, int],
requestHandler: Type[SimpleXMLRPCRequestHandler] = ...,
logRequests: bool = ...,
allow_none: bool = ...,
encoding: Optional[str] = ...,
bind_and_activate: bool = ...,
use_builtin_types: bool = ...,
) -> None: ...
class MultiPathXMLRPCServer(SimpleXMLRPCServer): # undocumented
dispatchers: Dict[str, SimpleXMLRPCDispatcher]
allow_none: bool
encoding: str
def __init__(self, addr: Tuple[str, int], requestHandler: Type[SimpleXMLRPCRequestHandler] = ..., logRequests: bool = ..., allow_none: bool = ..., encoding: Optional[str] = ..., bind_and_activate: bool = ..., use_builtin_types: bool = ...) -> None: ...
def __init__(
self,
addr: Tuple[str, int],
requestHandler: Type[SimpleXMLRPCRequestHandler] = ...,
logRequests: bool = ...,
allow_none: bool = ...,
encoding: Optional[str] = ...,
bind_and_activate: bool = ...,
use_builtin_types: bool = ...,
) -> None: ...
def add_dispatcher(self, path: str, dispatcher: SimpleXMLRPCDispatcher) -> SimpleXMLRPCDispatcher: ...
def get_dispatcher(self, path: str) -> SimpleXMLRPCDispatcher: ...
def _marshaled_dispatch(self, data: str, dispatch_method: Optional[Callable[[Optional[str], Tuple[_Marshallable, ...]], Union[Fault, Tuple[_Marshallable, ...]]]] = ..., path: Optional[Any] = ...) -> str: ...
def _marshaled_dispatch(
self,
data: str,
dispatch_method: Optional[
Callable[[Optional[str], Tuple[_Marshallable, ...]], Union[Fault, Tuple[_Marshallable, ...]]]
] = ...,
path: Optional[Any] = ...,
) -> str: ...
class CGIXMLRPCRequestHandler(SimpleXMLRPCDispatcher):
def __init__(self, allow_none: bool = ..., encoding: Optional[str] = ..., use_builtin_types: bool = ...) -> None: ...
def handle_xmlrpc(self, request_text: str) -> None: ...
def handle_get(self) -> None: ...
def handle_request(self, request_text: Optional[str] = ...) -> None: ...
class ServerHTMLDoc(pydoc.HTMLDoc): # undocumented
def docroutine(self, object: object, name: str, mod: Optional[str] = ..., funcs: Mapping[str, str] = ..., classes: Mapping[str, str] = ..., methods: Mapping[str, str] = ..., cl: Optional[type] = ...) -> str: ... # type: ignore
def docserver(self, server_name: str, package_documentation: str, methods: Dict[str, str]) -> str: ...
@@ -99,7 +135,6 @@ class XMLRPCDocGenerator: # undocumented
server_name: str
server_documentation: str
server_title: str
def __init__(self) -> None: ...
def set_server_title(self, server_title: str) -> None: ...
def set_server_name(self, server_name: str) -> None: ...
@@ -107,13 +142,19 @@ class XMLRPCDocGenerator: # undocumented
def generate_html_documentation(self) -> str: ...
class DocXMLRPCRequestHandler(SimpleXMLRPCRequestHandler):
def do_GET(self) -> None: ...
class DocXMLRPCServer(SimpleXMLRPCServer, XMLRPCDocGenerator):
def __init__(self, addr: Tuple[str, int], requestHandler: Type[SimpleXMLRPCRequestHandler] = ..., logRequests: bool = ..., allow_none: bool = ..., encoding: Optional[str] = ..., bind_and_activate: bool = ..., use_builtin_types: bool = ...) -> None: ...
def __init__(
self,
addr: Tuple[str, int],
requestHandler: Type[SimpleXMLRPCRequestHandler] = ...,
logRequests: bool = ...,
allow_none: bool = ...,
encoding: Optional[str] = ...,
bind_and_activate: bool = ...,
use_builtin_types: bool = ...,
) -> None: ...
class DocCGIXMLRPCRequestHandler(CGIXMLRPCRequestHandler, XMLRPCDocGenerator):
def __init__(self) -> None: ...