mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-07 12:44:28 +08:00
Use PEP 585 syntax wherever possible (#6717)
This commit is contained in:
@@ -6,16 +6,16 @@ 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, Protocol, Tuple, Type, Union, overload
|
||||
from typing import Any, Callable, Iterable, Mapping, Protocol, Type, Union, overload
|
||||
from typing_extensions import Literal
|
||||
|
||||
class _SupportsTimeTuple(Protocol):
|
||||
def timetuple(self) -> time.struct_time: ...
|
||||
|
||||
_DateTimeComparable = Union[DateTime, datetime, str, _SupportsTimeTuple]
|
||||
_Marshallable = Union[None, bool, int, float, str, bytes, Tuple[Any, ...], List[Any], Dict[Any, Any], datetime, DateTime, Binary]
|
||||
_XMLDate = Union[int, datetime, Tuple[int, ...], time.struct_time]
|
||||
_HostType = Union[Tuple[str, Dict[str, str]], str]
|
||||
_Marshallable = Union[None, bool, int, float, str, bytes, tuple[Any, ...], list[Any], dict[Any, Any], datetime, DateTime, Binary]
|
||||
_XMLDate = Union[int, datetime, tuple[int, ...], time.struct_time]
|
||||
_HostType = Union[tuple[str, dict[str, str]], str]
|
||||
|
||||
def escape(s: str) -> str: ... # undocumented
|
||||
|
||||
@@ -63,7 +63,7 @@ def _strftime(value: _XMLDate) -> str: ... # undocumented
|
||||
class DateTime:
|
||||
|
||||
value: str # undocumented
|
||||
def __init__(self, value: 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: ...
|
||||
@@ -135,7 +135,7 @@ class Unmarshaller:
|
||||
_use_datetime: bool
|
||||
_use_builtin_types: bool
|
||||
def __init__(self, use_datetime: bool = ..., use_builtin_types: bool = ...) -> None: ...
|
||||
def close(self) -> Tuple[_Marshallable, ...]: ...
|
||||
def close(self) -> tuple[_Marshallable, ...]: ...
|
||||
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: ...
|
||||
@@ -159,7 +159,7 @@ class Unmarshaller:
|
||||
|
||||
class _MultiCallMethod: # undocumented
|
||||
|
||||
__call_list: list[tuple[str, Tuple[_Marshallable, ...]]]
|
||||
__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: ...
|
||||
@@ -174,7 +174,7 @@ class MultiCallIterator: # undocumented
|
||||
class MultiCall:
|
||||
|
||||
__server: ServerProxy
|
||||
__call_list: list[tuple[str, Tuple[_Marshallable, ...]]]
|
||||
__call_list: list[tuple[str, tuple[_Marshallable, ...]]]
|
||||
def __init__(self, server: ServerProxy) -> None: ...
|
||||
def __getattr__(self, item: str) -> _MultiCallMethod: ...
|
||||
def __call__(self) -> MultiCallIterator: ...
|
||||
@@ -186,13 +186,13 @@ FastUnmarshaller: Unmarshaller | None
|
||||
|
||||
def getparser(use_datetime: bool = ..., use_builtin_types: bool = ...) -> tuple[ExpatParser, Unmarshaller]: ...
|
||||
def dumps(
|
||||
params: Fault | Tuple[_Marshallable, ...],
|
||||
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, ...], str | None]: ...
|
||||
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
|
||||
|
||||
@@ -204,9 +204,9 @@ class GzipDecodedResponse(gzip.GzipFile): # undocumented
|
||||
|
||||
class _Method: # undocumented
|
||||
|
||||
__send: Callable[[str, Tuple[_Marshallable, ...]], _Marshallable]
|
||||
__send: Callable[[str, tuple[_Marshallable, ...]], _Marshallable]
|
||||
__name: str
|
||||
def __init__(self, send: Callable[[str, Tuple[_Marshallable, ...]], _Marshallable], name: str) -> None: ...
|
||||
def __init__(self, send: Callable[[str, tuple[_Marshallable, ...]], _Marshallable], name: str) -> None: ...
|
||||
def __getattr__(self, name: str) -> _Method: ...
|
||||
def __call__(self, *args: _Marshallable) -> _Marshallable: ...
|
||||
|
||||
@@ -228,10 +228,10 @@ class Transport:
|
||||
) -> 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 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, ...]: ...
|
||||
) -> 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: ...
|
||||
@@ -239,7 +239,7 @@ class Transport:
|
||||
def send_request(self, host: _HostType, handler: str, request_body: bytes, debug: bool) -> http.client.HTTPConnection: ...
|
||||
def send_headers(self, connection: http.client.HTTPConnection, headers: list[tuple[str, str]]) -> None: ...
|
||||
def send_content(self, connection: http.client.HTTPConnection, request_body: bytes) -> None: ...
|
||||
def parse_response(self, response: http.client.HTTPResponse) -> Tuple[_Marshallable, ...]: ...
|
||||
def parse_response(self, response: http.client.HTTPResponse) -> tuple[_Marshallable, ...]: ...
|
||||
|
||||
class SafeTransport(Transport):
|
||||
|
||||
@@ -304,6 +304,6 @@ class ServerProxy:
|
||||
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
|
||||
def __request(self, methodname: str, params: tuple[_Marshallable, ...]) -> tuple[_Marshallable, ...]: ... # undocumented
|
||||
|
||||
Server = ServerProxy
|
||||
|
||||
@@ -3,11 +3,11 @@ import pydoc
|
||||
import socketserver
|
||||
import sys
|
||||
from datetime import datetime
|
||||
from typing import Any, Callable, Dict, Iterable, List, Mapping, Pattern, Protocol, Tuple, Type, Union
|
||||
from typing import Any, Callable, Iterable, Mapping, Pattern, Protocol, Type, Union
|
||||
from xmlrpc.client import Fault
|
||||
|
||||
# TODO: Recursive type on tuple, list, dict
|
||||
_Marshallable = Union[None, bool, int, float, str, bytes, Tuple[Any, ...], List[Any], Dict[Any, Any], datetime]
|
||||
_Marshallable = Union[None, bool, int, float, str, bytes, tuple[Any, ...], list[Any], dict[Any, Any], datetime]
|
||||
|
||||
# The dispatch accepts anywhere from 0 to N arguments, no easy way to allow this in mypy
|
||||
class _DispatchArity0(Protocol):
|
||||
@@ -53,7 +53,7 @@ class SimpleXMLRPCDispatcher: # undocumented
|
||||
def _marshaled_dispatch(
|
||||
self,
|
||||
data: str,
|
||||
dispatch_method: Callable[[str | None, Tuple[_Marshallable, ...]], Fault | Tuple[_Marshallable, ...]] | None = ...,
|
||||
dispatch_method: Callable[[str | None, tuple[_Marshallable, ...]], Fault | tuple[_Marshallable, ...]] | None = ...,
|
||||
path: Any | None = ...,
|
||||
) -> str: ... # undocumented
|
||||
def system_listMethods(self) -> list[str]: ... # undocumented
|
||||
@@ -109,7 +109,7 @@ class MultiPathXMLRPCServer(SimpleXMLRPCServer): # undocumented
|
||||
def _marshaled_dispatch(
|
||||
self,
|
||||
data: str,
|
||||
dispatch_method: Callable[[str | None, Tuple[_Marshallable, ...]], Fault | Tuple[_Marshallable, ...]] | None = ...,
|
||||
dispatch_method: Callable[[str | None, tuple[_Marshallable, ...]], Fault | tuple[_Marshallable, ...]] | None = ...,
|
||||
path: Any | None = ...,
|
||||
) -> str: ...
|
||||
|
||||
|
||||
Reference in New Issue
Block a user