mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-07 12:44:28 +08:00
asyncio.events: various fixes (#3931)
- connect_accepted_socket isn't a member of AbstractEventLoop, only BaseEventLoop - fix types of arguments with defaults. some of these functions could have their signatures improved with overloads to reduce false negatives - correctly mark a positional-only argument - remove abstractmethod from methods that don't have abstractmethod and go unimplemented in practice
This commit is contained in:
@@ -192,18 +192,13 @@ class AbstractEventLoop(metaclass=ABCMeta):
|
||||
family: int = ..., flags: int = ..., sock: socket = ..., backlog: int = ...,
|
||||
ssl: _SSLContext = ..., reuse_address: Optional[bool] = ..., reuse_port: Optional[bool] = ...,
|
||||
ssl_handshake_timeout: Optional[float] = ..., start_serving: bool = ...) -> AbstractServer: ...
|
||||
@abstractmethod
|
||||
async def create_unix_connection(self, protocol_factory: _ProtocolFactory, path: str, *, ssl: _SSLContext = ...,
|
||||
sock: Optional[socket] = ..., server_hostname: str = ...,
|
||||
async def create_unix_connection(self, protocol_factory: _ProtocolFactory, path: Optional[str] = ..., *, ssl: _SSLContext = ...,
|
||||
sock: Optional[socket] = ..., server_hostname: Optional[str] = ...,
|
||||
ssl_handshake_timeout: Optional[float] = ...) -> _TransProtPair: ...
|
||||
@abstractmethod
|
||||
async def create_unix_server(self, protocol_factory: _ProtocolFactory, path: str, *, sock: Optional[socket] = ...,
|
||||
async def create_unix_server(self, protocol_factory: _ProtocolFactory, path: Optional[str] = ..., *, sock: Optional[socket] = ...,
|
||||
backlog: int = ..., ssl: _SSLContext = ..., ssl_handshake_timeout: Optional[float] = ...,
|
||||
start_serving: bool = ...) -> AbstractServer: ...
|
||||
@abstractmethod
|
||||
async def connect_accepted_socket(self, protocol_factory: _ProtocolFactory, sock: socket, *, ssl: _SSLContext = ...,
|
||||
ssl_handshake_timeout: Optional[float] = ...) -> _TransProtPair: ...
|
||||
@abstractmethod
|
||||
async def sendfile(self, transport: BaseTransport, file: IO[bytes], offset: int = ..., count: Optional[int] = ..., *,
|
||||
fallback: bool = ...) -> int: ...
|
||||
@abstractmethod
|
||||
@@ -225,15 +220,11 @@ class AbstractEventLoop(metaclass=ABCMeta):
|
||||
sock: socket, backlog: int = ..., ssl: _SSLContext = ...,
|
||||
reuse_address: Optional[bool] = ...,
|
||||
reuse_port: Optional[bool] = ...) -> AbstractServer: ...
|
||||
@abstractmethod
|
||||
async def create_unix_connection(self, protocol_factory: _ProtocolFactory, path: str, *,
|
||||
ssl: _SSLContext = ..., sock: Optional[socket] = ...,
|
||||
server_hostname: str = ...) -> _TransProtPair: ...
|
||||
@abstractmethod
|
||||
server_hostname: Optional[str] = ...) -> _TransProtPair: ...
|
||||
async def create_unix_server(self, protocol_factory: _ProtocolFactory, path: str, *,
|
||||
sock: Optional[socket] = ..., backlog: int = ..., ssl: _SSLContext = ...) -> AbstractServer: ...
|
||||
@abstractmethod
|
||||
async def connect_accepted_socket(self, protocol_factory: _ProtocolFactory, sock: socket, *, ssl: _SSLContext = ...) -> _TransProtPair: ...
|
||||
@abstractmethod
|
||||
async def create_datagram_endpoint(self, protocol_factory: _ProtocolFactory,
|
||||
local_addr: Optional[Tuple[str, int]] = ..., remote_addr: Optional[Tuple[str, int]] = ..., *,
|
||||
@@ -332,7 +323,7 @@ def new_event_loop() -> AbstractEventLoop: ...
|
||||
def get_child_watcher() -> AbstractChildWatcher: ...
|
||||
def set_child_watcher(watcher: AbstractChildWatcher) -> None: ...
|
||||
|
||||
def _set_running_loop(loop: Optional[AbstractEventLoop]) -> None: ...
|
||||
def _set_running_loop(__loop: Optional[AbstractEventLoop]) -> None: ...
|
||||
def _get_running_loop() -> AbstractEventLoop: ...
|
||||
|
||||
if sys.version_info >= (3, 7):
|
||||
|
||||
@@ -46,35 +46,4 @@ class _ProactorSocketTransport(_ProactorReadPipeTransport, _ProactorBaseWritePip
|
||||
def write_eof(self) -> None: ...
|
||||
|
||||
class BaseProactorEventLoop(base_events.BaseEventLoop):
|
||||
|
||||
def __init__(self, proactor: Any) -> None: ...
|
||||
# The methods below don't actually exist directly, ProactorEventLoops do not implement them. However, they are
|
||||
# needed to satisfy mypy
|
||||
if sys.version_info >= (3, 7):
|
||||
async def create_unix_connection(
|
||||
self,
|
||||
protocol_factory: events._ProtocolFactory,
|
||||
path: _Path,
|
||||
*,
|
||||
ssl: events._SSLContext = ...,
|
||||
sock: Optional[socket] = ...,
|
||||
server_hostname: str = ...,
|
||||
ssl_handshake_timeout: Optional[float] = ...,
|
||||
) -> events._TransProtPair: ...
|
||||
async def create_unix_server(
|
||||
self,
|
||||
protocol_factory: events._ProtocolFactory,
|
||||
path: _Path,
|
||||
*,
|
||||
sock: Optional[socket] = ...,
|
||||
backlog: int = ...,
|
||||
ssl: events._SSLContext = ...,
|
||||
ssl_handshake_timeout: Optional[float] = ...,
|
||||
start_serving: bool = ...,
|
||||
) -> events.AbstractServer: ...
|
||||
else:
|
||||
async def create_unix_connection(self, protocol_factory: events._ProtocolFactory, path: str, *,
|
||||
ssl: events._SSLContext = ..., sock: Optional[socket] = ...,
|
||||
server_hostname: str = ...) -> events._TransProtPair: ...
|
||||
async def create_unix_server(self, protocol_factory: events._ProtocolFactory, path: str, *,
|
||||
sock: Optional[socket] = ..., backlog: int = ..., ssl: events._SSLContext = ...) -> events.AbstractServer: ...
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import selectors
|
||||
import sys
|
||||
from socket import socket
|
||||
from typing import Optional, Union
|
||||
from typing import Any, Optional, Union
|
||||
|
||||
from . import base_events, events
|
||||
|
||||
@@ -12,33 +12,4 @@ else:
|
||||
_Path = str
|
||||
|
||||
class BaseSelectorEventLoop(base_events.BaseEventLoop):
|
||||
|
||||
def __init__(self, selector: Optional[selectors.BaseSelector] = ...) -> None: ...
|
||||
if sys.version_info >= (3, 7):
|
||||
async def create_unix_connection(
|
||||
self,
|
||||
protocol_factory: events._ProtocolFactory,
|
||||
path: _Path,
|
||||
*,
|
||||
ssl: events._SSLContext = ...,
|
||||
sock: Optional[socket] = ...,
|
||||
server_hostname: str = ...,
|
||||
ssl_handshake_timeout: Optional[float] = ...,
|
||||
) -> events._TransProtPair: ...
|
||||
async def create_unix_server(
|
||||
self,
|
||||
protocol_factory: events._ProtocolFactory,
|
||||
path: _Path,
|
||||
*,
|
||||
sock: Optional[socket] = ...,
|
||||
backlog: int = ...,
|
||||
ssl: events._SSLContext = ...,
|
||||
ssl_handshake_timeout: Optional[float] = ...,
|
||||
start_serving: bool = ...,
|
||||
) -> events.AbstractServer: ...
|
||||
else:
|
||||
async def create_unix_connection(self, protocol_factory: events._ProtocolFactory, path: str, *,
|
||||
ssl: events._SSLContext = ..., sock: Optional[socket] = ...,
|
||||
server_hostname: str = ...) -> events._TransProtPair: ...
|
||||
async def create_unix_server(self, protocol_factory: events._ProtocolFactory, path: str, *,
|
||||
sock: Optional[socket] = ..., backlog: int = ..., ssl: events._SSLContext = ...) -> events.AbstractServer: ...
|
||||
|
||||
@@ -15,6 +15,7 @@ asyncio.futures._TracebackLogger.__init__
|
||||
asyncio.protocols.BufferedProtocol
|
||||
asyncio.runners
|
||||
asyncio.tasks.Task.__init__
|
||||
asyncio.unix_events._UnixSelectorEventLoop.create_unix_server
|
||||
bdb.GENERATOR_AND_COROUTINE_FLAGS
|
||||
builtins.str.maketrans
|
||||
cmath.log
|
||||
|
||||
@@ -8,6 +8,7 @@ asyncio.futures._TracebackLogger.__init__
|
||||
asyncio.protocols.BufferedProtocol
|
||||
asyncio.runners
|
||||
asyncio.tasks.Task._wakeup
|
||||
asyncio.unix_events._UnixSelectorEventLoop.create_unix_server
|
||||
builtins.str.maketrans
|
||||
cmath.log
|
||||
codecs.StreamRecoder.seek
|
||||
|
||||
@@ -2,14 +2,12 @@ _bisect.bisect
|
||||
_bisect.insort
|
||||
_tracemalloc._get_object_traceback
|
||||
_tracemalloc.start
|
||||
asyncio.AbstractEventLoop.create_unix_server
|
||||
asyncio.AbstractEventLoop.sock_sendfile
|
||||
asyncio.Future.__init__
|
||||
asyncio.Future._callbacks
|
||||
asyncio.Future._schedule_callbacks
|
||||
asyncio.Handle.__init__
|
||||
asyncio.TimerHandle.__init__
|
||||
asyncio.events.AbstractEventLoop.create_unix_server
|
||||
asyncio.events.AbstractEventLoop.sock_sendfile
|
||||
asyncio.events.Handle.__init__
|
||||
asyncio.events.TimerHandle.__init__
|
||||
@@ -17,8 +15,6 @@ asyncio.exceptions
|
||||
asyncio.futures.Future.__init__
|
||||
asyncio.futures.Future._callbacks
|
||||
asyncio.futures.Future._schedule_callbacks
|
||||
asyncio.proactor_events.BaseProactorEventLoop.create_unix_server
|
||||
asyncio.selector_events.BaseSelectorEventLoop.create_unix_server
|
||||
builtins.dict.get
|
||||
builtins.reversed
|
||||
builtins.str.maketrans
|
||||
|
||||
@@ -5,7 +5,6 @@ _thread._ExceptHookArgs
|
||||
_tracemalloc._get_object_traceback
|
||||
_tracemalloc.start
|
||||
_weakref.getweakrefcount
|
||||
asyncio.AbstractEventLoop.create_unix_server
|
||||
asyncio.AbstractEventLoop.sock_sendfile
|
||||
asyncio.Future.__init__
|
||||
asyncio.Future._callbacks
|
||||
@@ -19,21 +18,16 @@ asyncio.Task.set_exception
|
||||
asyncio.Task.set_name
|
||||
asyncio.Task.set_result
|
||||
asyncio.TimerHandle.__init__
|
||||
asyncio._set_running_loop
|
||||
asyncio.events.AbstractEventLoop.create_unix_server
|
||||
asyncio.events.AbstractEventLoop.sock_sendfile
|
||||
asyncio.events.Handle.__init__
|
||||
asyncio.events.TimerHandle.__init__
|
||||
asyncio.events._set_running_loop
|
||||
asyncio.futures.Future.__init__
|
||||
asyncio.futures.Future._callbacks
|
||||
asyncio.futures.Future._schedule_callbacks
|
||||
asyncio.futures.Future.remove_done_callback
|
||||
asyncio.futures.Future.set_exception
|
||||
asyncio.futures.Future.set_result
|
||||
asyncio.proactor_events.BaseProactorEventLoop.create_unix_server
|
||||
asyncio.proactor_events._ProactorBasePipeTransport.__del__
|
||||
asyncio.selector_events.BaseSelectorEventLoop.create_unix_server
|
||||
asyncio.tasks.Task.remove_done_callback
|
||||
asyncio.tasks.Task.set_exception
|
||||
asyncio.tasks.Task.set_name
|
||||
|
||||
@@ -15,8 +15,6 @@ abc.abstractstaticmethod
|
||||
aifc.open
|
||||
aifc.openfp
|
||||
argparse.Namespace.__getattr__
|
||||
asyncio.AbstractEventLoop.connect_accepted_socket
|
||||
asyncio.AbstractEventLoop.create_unix_connection
|
||||
asyncio.BaseChildWatcher
|
||||
asyncio.BaseEventLoop.subprocess_exec
|
||||
asyncio.Condition.acquire
|
||||
@@ -32,8 +30,6 @@ asyncio.Task.get_stack
|
||||
asyncio.Task.print_stack
|
||||
asyncio.WriteTransport.set_write_buffer_limits
|
||||
asyncio.base_events.BaseEventLoop.subprocess_exec
|
||||
asyncio.events.AbstractEventLoop.connect_accepted_socket
|
||||
asyncio.events.AbstractEventLoop.create_unix_connection
|
||||
asyncio.futures.Future._copy_state
|
||||
asyncio.futures.wrap_future
|
||||
asyncio.locks.Condition.acquire
|
||||
@@ -41,11 +37,9 @@ asyncio.locks.Condition.locked
|
||||
asyncio.locks.Condition.release
|
||||
asyncio.open_connection
|
||||
asyncio.open_unix_connection
|
||||
asyncio.proactor_events.BaseProactorEventLoop.create_unix_connection
|
||||
asyncio.proactor_events.BaseProactorEventLoop.sock_recv
|
||||
asyncio.queues.Queue._consume_done_getters
|
||||
asyncio.queues.Queue._consume_done_putters
|
||||
asyncio.selector_events.BaseSelectorEventLoop.create_unix_connection
|
||||
asyncio.selector_events.BaseSelectorEventLoop.sock_recv
|
||||
asyncio.sleep
|
||||
asyncio.start_unix_server
|
||||
@@ -59,8 +53,6 @@ asyncio.tasks.Task.print_stack
|
||||
asyncio.tasks.sleep
|
||||
asyncio.transports.WriteTransport.set_write_buffer_limits
|
||||
asyncio.transports._FlowControlMixin.set_write_buffer_limits
|
||||
asyncio.unix_events._UnixSelectorEventLoop.create_unix_connection
|
||||
asyncio.unix_events._UnixSelectorEventLoop.create_unix_server
|
||||
asyncio.windows_events
|
||||
asyncio.windows_utils
|
||||
asyncio.wrap_future
|
||||
|
||||
Reference in New Issue
Block a user