Fix _DispatchProtocol in xmlrpc.server (#4165)

This commit is contained in:
Rune Tynan
2020-06-21 16:42:14 -04:00
committed by GitHub
parent aca6bd7e88
commit 79111ee8ed

View File

@@ -7,9 +7,23 @@ from xmlrpc.client import Fault
from typing import Any, Callable, Dict, Iterable, List, Mapping, Optional, Pattern, Protocol, Tuple, Type, Union
from datetime import datetime
_Marshallable = Union[None, bool, int, float, str, bytes, tuple, list, dict, datetime]
class _DispatchProtocol(Protocol):
_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: ...
class _DispatchArityN(Protocol):
def __call__(self, *args: _Marshallable) -> _Marshallable: ...
_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