mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-07 20:54:28 +08:00
Big diff: Use new "|" union syntax (#5872)
This commit is contained in:
@@ -6,7 +6,7 @@ from _typeshed import Self, SupportsRead, SupportsWrite
|
||||
from datetime import datetime
|
||||
from io import BytesIO
|
||||
from types import TracebackType
|
||||
from typing import Any, Callable, Dict, Iterable, List, Mapping, Optional, Protocol, Tuple, Type, Union, overload
|
||||
from typing import Any, Callable, Dict, Iterable, List, Mapping, Protocol, Tuple, Type, Union, overload
|
||||
from typing_extensions import Literal
|
||||
|
||||
class _SupportsTimeTuple(Protocol):
|
||||
@@ -63,7 +63,7 @@ def _strftime(value: _XMLDate) -> str: ... # undocumented
|
||||
class DateTime:
|
||||
|
||||
value: str # undocumented
|
||||
def __init__(self, value: Union[int, str, datetime, time.struct_time, Tuple[int, ...]] = ...) -> None: ...
|
||||
def __init__(self, value: int | str | datetime | time.struct_time | Tuple[int, ...] = ...) -> None: ...
|
||||
def __lt__(self, other: _DateTimeComparable) -> bool: ...
|
||||
def __le__(self, other: _DateTimeComparable) -> bool: ...
|
||||
def __gt__(self, other: _DateTimeComparable) -> bool: ...
|
||||
@@ -80,7 +80,7 @@ def _datetime_type(data: str) -> datetime: ... # undocumented
|
||||
class Binary:
|
||||
|
||||
data: bytes
|
||||
def __init__(self, data: Optional[bytes] = ...) -> None: ...
|
||||
def __init__(self, data: bytes | None = ...) -> None: ...
|
||||
def decode(self, data: bytes) -> None: ...
|
||||
def encode(self, out: SupportsWrite[str]) -> None: ...
|
||||
|
||||
@@ -90,7 +90,7 @@ 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 feed(self, data: str | bytes) -> None: ...
|
||||
def close(self) -> None: ...
|
||||
|
||||
class Marshaller:
|
||||
@@ -101,11 +101,11 @@ class Marshaller:
|
||||
|
||||
memo: Dict[Any, None]
|
||||
data: None
|
||||
encoding: Optional[str]
|
||||
encoding: str | None
|
||||
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
|
||||
def __init__(self, encoding: str | None = ..., allow_none: bool = ...) -> None: ...
|
||||
def dumps(self, values: Fault | Iterable[_Marshallable]) -> str: ...
|
||||
def __dump(self, value: _Marshallable, write: Callable[[str], Any]) -> None: ... # undocumented
|
||||
def dump_nil(self, value: None, write: Callable[[str], Any]) -> None: ...
|
||||
def dump_bool(self, value: bool, write: Callable[[str], Any]) -> None: ...
|
||||
def dump_long(self, value: int, write: Callable[[str], Any]) -> None: ...
|
||||
@@ -124,19 +124,19 @@ class Unmarshaller:
|
||||
|
||||
dispatch: Dict[str, Callable[[Unmarshaller, str], None]] = ...
|
||||
|
||||
_type: Optional[str]
|
||||
_type: str | None
|
||||
_stack: List[_Marshallable]
|
||||
_marks: List[int]
|
||||
_data: List[str]
|
||||
_value: bool
|
||||
_methodname: Optional[str]
|
||||
_methodname: str | None
|
||||
_encoding: str
|
||||
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]: ...
|
||||
def getmethodname(self) -> str | None: ...
|
||||
def xml(self, encoding: str, standalone: Any) -> None: ... # Standalone is ignored
|
||||
def start(self, tag: str, attrs: Dict[str, str]) -> None: ...
|
||||
def data(self, text: str) -> None: ...
|
||||
@@ -180,21 +180,19 @@ class MultiCall:
|
||||
def __call__(self) -> MultiCallIterator: ...
|
||||
|
||||
# A little white lie
|
||||
FastMarshaller: Optional[Marshaller]
|
||||
FastParser: Optional[ExpatParser]
|
||||
FastUnmarshaller: Optional[Unmarshaller]
|
||||
FastMarshaller: Marshaller | None
|
||||
FastParser: ExpatParser | None
|
||||
FastUnmarshaller: Unmarshaller | None
|
||||
|
||||
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] = ...,
|
||||
params: Fault | Tuple[_Marshallable, ...],
|
||||
methodname: str | None = ...,
|
||||
methodresponse: bool | None = ...,
|
||||
encoding: str | None = ...,
|
||||
allow_none: bool = ...,
|
||||
) -> str: ...
|
||||
def loads(
|
||||
data: str, use_datetime: bool = ..., use_builtin_types: bool = ...
|
||||
) -> Tuple[Tuple[_Marshallable, ...], Optional[str]]: ...
|
||||
def loads(data: str, use_datetime: bool = ..., use_builtin_types: bool = ...) -> Tuple[Tuple[_Marshallable, ...], str | None]: ...
|
||||
def gzip_encode(data: bytes) -> bytes: ... # undocumented
|
||||
def gzip_decode(data: bytes, max_decode: int = ...) -> bytes: ... # undocumented
|
||||
|
||||
@@ -216,11 +214,11 @@ class Transport:
|
||||
|
||||
user_agent: str = ...
|
||||
accept_gzip_encoding: bool = ...
|
||||
encode_threshold: Optional[int] = ...
|
||||
encode_threshold: int | None = ...
|
||||
|
||||
_use_datetime: bool
|
||||
_use_builtin_types: bool
|
||||
_connection: Tuple[Optional[_HostType], Optional[http.client.HTTPConnection]]
|
||||
_connection: Tuple[_HostType | None, http.client.HTTPConnection | None]
|
||||
_headers: List[Tuple[str, str]]
|
||||
_extra_headers: List[Tuple[str, str]]
|
||||
|
||||
@@ -252,10 +250,10 @@ class SafeTransport(Transport):
|
||||
use_builtin_types: bool = ...,
|
||||
*,
|
||||
headers: Iterable[Tuple[str, str]] = ...,
|
||||
context: Optional[Any] = ...,
|
||||
context: Any | None = ...,
|
||||
) -> None: ...
|
||||
else:
|
||||
def __init__(self, use_datetime: bool = ..., use_builtin_types: bool = ..., *, context: Optional[Any] = ...) -> None: ...
|
||||
def __init__(self, use_datetime: bool = ..., use_builtin_types: bool = ..., *, context: Any | None = ...) -> None: ...
|
||||
def make_connection(self, host: _HostType) -> http.client.HTTPSConnection: ...
|
||||
|
||||
class ServerProxy:
|
||||
@@ -271,28 +269,28 @@ class ServerProxy:
|
||||
def __init__(
|
||||
self,
|
||||
uri: str,
|
||||
transport: Optional[Transport] = ...,
|
||||
encoding: Optional[str] = ...,
|
||||
transport: Transport | None = ...,
|
||||
encoding: str | None = ...,
|
||||
verbose: bool = ...,
|
||||
allow_none: bool = ...,
|
||||
use_datetime: bool = ...,
|
||||
use_builtin_types: bool = ...,
|
||||
*,
|
||||
headers: Iterable[Tuple[str, str]] = ...,
|
||||
context: Optional[Any] = ...,
|
||||
context: Any | None = ...,
|
||||
) -> None: ...
|
||||
else:
|
||||
def __init__(
|
||||
self,
|
||||
uri: str,
|
||||
transport: Optional[Transport] = ...,
|
||||
encoding: Optional[str] = ...,
|
||||
transport: Transport | None = ...,
|
||||
encoding: str | None = ...,
|
||||
verbose: bool = ...,
|
||||
allow_none: bool = ...,
|
||||
use_datetime: bool = ...,
|
||||
use_builtin_types: bool = ...,
|
||||
*,
|
||||
context: Optional[Any] = ...,
|
||||
context: Any | None = ...,
|
||||
) -> None: ...
|
||||
def __getattr__(self, name: str) -> _Method: ...
|
||||
@overload
|
||||
@@ -300,10 +298,10 @@ class ServerProxy:
|
||||
@overload
|
||||
def __call__(self, attr: Literal["transport"]) -> Transport: ...
|
||||
@overload
|
||||
def __call__(self, attr: str) -> Union[Callable[[], None], Transport]: ...
|
||||
def __call__(self, attr: str) -> Callable[[], None] | Transport: ...
|
||||
def __enter__(self: Self) -> Self: ...
|
||||
def __exit__(
|
||||
self, exc_type: Optional[Type[BaseException]], exc_val: Optional[BaseException], exc_tb: Optional[TracebackType]
|
||||
self, exc_type: Type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None
|
||||
) -> None: ...
|
||||
def __close(self) -> None: ... # undocumented
|
||||
def __request(self, methodname: str, params: Tuple[_Marshallable, ...]) -> Tuple[_Marshallable, ...]: ... # undocumented
|
||||
|
||||
@@ -3,7 +3,7 @@ import pydoc
|
||||
import socketserver
|
||||
import sys
|
||||
from datetime import datetime
|
||||
from typing import Any, Callable, Dict, Iterable, List, Mapping, Optional, Pattern, Protocol, Tuple, Type, Union
|
||||
from typing import Any, Callable, Dict, Iterable, List, Mapping, Pattern, Protocol, Tuple, Type, Union
|
||||
from xmlrpc.client import Fault
|
||||
|
||||
_Marshallable = Union[
|
||||
@@ -39,27 +39,23 @@ def list_public_methods(obj: Any) -> List[str]: ... # undocumented
|
||||
class SimpleXMLRPCDispatcher: # undocumented
|
||||
|
||||
funcs: Dict[str, _DispatchProtocol]
|
||||
instance: Optional[Any]
|
||||
instance: Any | None
|
||||
allow_none: bool
|
||||
encoding: str
|
||||
use_builtin_types: bool
|
||||
def __init__(self, allow_none: bool = ..., encoding: Optional[str] = ..., use_builtin_types: bool = ...) -> None: ...
|
||||
def __init__(self, allow_none: bool = ..., encoding: str | None = ..., 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: _DispatchProtocol | None = ..., name: str | None = ...) -> Callable[..., Any]: ...
|
||||
else:
|
||||
def register_function(self, function: _DispatchProtocol, name: Optional[str] = ...) -> Callable[..., Any]: ...
|
||||
def register_function(self, function: _DispatchProtocol, name: str | None = ...) -> 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] = ...,
|
||||
dispatch_method: Callable[[str | None, Tuple[_Marshallable, ...]], Fault | Tuple[_Marshallable, ...]] | None = ...,
|
||||
path: Any | None = ...,
|
||||
) -> str: ... # undocumented
|
||||
def system_listMethods(self) -> List[str]: ... # undocumented
|
||||
def system_methodSignature(self, method_name: str) -> str: ... # undocumented
|
||||
@@ -75,9 +71,9 @@ class SimpleXMLRPCRequestHandler(http.server.BaseHTTPRequestHandler):
|
||||
def accept_encodings(self) -> Dict[str, float]: ...
|
||||
def is_rpc_path_valid(self) -> bool: ...
|
||||
def do_POST(self) -> None: ...
|
||||
def decode_request_content(self, data: bytes) -> Optional[bytes]: ...
|
||||
def decode_request_content(self, data: bytes) -> bytes | None: ...
|
||||
def report_404(self) -> None: ...
|
||||
def log_request(self, code: Union[int, str] = ..., size: Union[int, str] = ...) -> None: ...
|
||||
def log_request(self, code: int | str = ..., size: int | str = ...) -> None: ...
|
||||
|
||||
class SimpleXMLRPCServer(socketserver.TCPServer, SimpleXMLRPCDispatcher):
|
||||
|
||||
@@ -89,7 +85,7 @@ class SimpleXMLRPCServer(socketserver.TCPServer, SimpleXMLRPCDispatcher):
|
||||
requestHandler: Type[SimpleXMLRPCRequestHandler] = ...,
|
||||
logRequests: bool = ...,
|
||||
allow_none: bool = ...,
|
||||
encoding: Optional[str] = ...,
|
||||
encoding: str | None = ...,
|
||||
bind_and_activate: bool = ...,
|
||||
use_builtin_types: bool = ...,
|
||||
) -> None: ...
|
||||
@@ -105,7 +101,7 @@ class MultiPathXMLRPCServer(SimpleXMLRPCServer): # undocumented
|
||||
requestHandler: Type[SimpleXMLRPCRequestHandler] = ...,
|
||||
logRequests: bool = ...,
|
||||
allow_none: bool = ...,
|
||||
encoding: Optional[str] = ...,
|
||||
encoding: str | None = ...,
|
||||
bind_and_activate: bool = ...,
|
||||
use_builtin_types: bool = ...,
|
||||
) -> None: ...
|
||||
@@ -114,20 +110,18 @@ class MultiPathXMLRPCServer(SimpleXMLRPCServer): # undocumented
|
||||
def _marshaled_dispatch(
|
||||
self,
|
||||
data: str,
|
||||
dispatch_method: Optional[
|
||||
Callable[[Optional[str], Tuple[_Marshallable, ...]], Union[Fault, Tuple[_Marshallable, ...]]]
|
||||
] = ...,
|
||||
path: Optional[Any] = ...,
|
||||
dispatch_method: Callable[[str | None, Tuple[_Marshallable, ...]], Fault | Tuple[_Marshallable, ...]] | None = ...,
|
||||
path: Any | None = ...,
|
||||
) -> str: ...
|
||||
|
||||
class CGIXMLRPCRequestHandler(SimpleXMLRPCDispatcher):
|
||||
def __init__(self, allow_none: bool = ..., encoding: Optional[str] = ..., use_builtin_types: bool = ...) -> None: ...
|
||||
def __init__(self, allow_none: bool = ..., encoding: str | None = ..., 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: ...
|
||||
def handle_request(self, request_text: str | None = ...) -> 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 docroutine(self, object: object, name: str, mod: str | None = ..., funcs: Mapping[str, str] = ..., classes: Mapping[str, str] = ..., methods: Mapping[str, str] = ..., cl: type | None = ...) -> str: ... # type: ignore
|
||||
def docserver(self, server_name: str, package_documentation: str, methods: Dict[str, str]) -> str: ...
|
||||
|
||||
class XMLRPCDocGenerator: # undocumented
|
||||
@@ -151,7 +145,7 @@ class DocXMLRPCServer(SimpleXMLRPCServer, XMLRPCDocGenerator):
|
||||
requestHandler: Type[SimpleXMLRPCRequestHandler] = ...,
|
||||
logRequests: bool = ...,
|
||||
allow_none: bool = ...,
|
||||
encoding: Optional[str] = ...,
|
||||
encoding: str | None = ...,
|
||||
bind_and_activate: bool = ...,
|
||||
use_builtin_types: bool = ...,
|
||||
) -> None: ...
|
||||
|
||||
Reference in New Issue
Block a user