mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-20 19:01:15 +08:00
Return concrete server from abstract event loop (#5566)
https://docs.python.org/3/library/asyncio-eventloop.html?highlight=abstracteventloop#creating-network-servers documents the methods as returning a concrete server object.
This commit is contained in:
@@ -2,15 +2,17 @@ import ssl
|
||||
import sys
|
||||
from _typeshed import FileDescriptorLike
|
||||
from abc import ABCMeta, abstractmethod
|
||||
from asyncio.futures import Future
|
||||
from asyncio.protocols import BaseProtocol
|
||||
from asyncio.tasks import Task
|
||||
from asyncio.transports import BaseTransport
|
||||
from asyncio.unix_events import AbstractChildWatcher
|
||||
from socket import AddressFamily, SocketKind, _Address, _RetAddress, socket
|
||||
from typing import IO, Any, Awaitable, Callable, Dict, Generator, List, Optional, Sequence, Tuple, TypeVar, Union, overload
|
||||
from typing_extensions import Literal
|
||||
|
||||
from .base_events import Server
|
||||
from .futures import Future
|
||||
from .protocols import BaseProtocol
|
||||
from .tasks import Task
|
||||
from .transports import BaseTransport
|
||||
from .unix_events import AbstractChildWatcher
|
||||
|
||||
if sys.version_info >= (3, 7):
|
||||
from contextvars import Context
|
||||
|
||||
@@ -261,7 +263,7 @@ class AbstractEventLoop(metaclass=ABCMeta):
|
||||
reuse_port: Optional[bool] = ...,
|
||||
ssl_handshake_timeout: Optional[float] = ...,
|
||||
start_serving: bool = ...,
|
||||
) -> AbstractServer: ...
|
||||
) -> Server: ...
|
||||
@overload
|
||||
@abstractmethod
|
||||
async def create_server(
|
||||
@@ -279,7 +281,7 @@ class AbstractEventLoop(metaclass=ABCMeta):
|
||||
reuse_port: Optional[bool] = ...,
|
||||
ssl_handshake_timeout: Optional[float] = ...,
|
||||
start_serving: bool = ...,
|
||||
) -> AbstractServer: ...
|
||||
) -> Server: ...
|
||||
async def create_unix_connection(
|
||||
self,
|
||||
protocol_factory: _ProtocolFactory,
|
||||
@@ -300,7 +302,7 @@ class AbstractEventLoop(metaclass=ABCMeta):
|
||||
ssl: _SSLContext = ...,
|
||||
ssl_handshake_timeout: Optional[float] = ...,
|
||||
start_serving: bool = ...,
|
||||
) -> AbstractServer: ...
|
||||
) -> Server: ...
|
||||
@abstractmethod
|
||||
async def sendfile(
|
||||
self,
|
||||
@@ -338,7 +340,7 @@ class AbstractEventLoop(metaclass=ABCMeta):
|
||||
ssl: _SSLContext = ...,
|
||||
reuse_address: Optional[bool] = ...,
|
||||
reuse_port: Optional[bool] = ...,
|
||||
) -> AbstractServer: ...
|
||||
) -> Server: ...
|
||||
@overload
|
||||
@abstractmethod
|
||||
async def create_server(
|
||||
@@ -354,7 +356,7 @@ class AbstractEventLoop(metaclass=ABCMeta):
|
||||
ssl: _SSLContext = ...,
|
||||
reuse_address: Optional[bool] = ...,
|
||||
reuse_port: Optional[bool] = ...,
|
||||
) -> AbstractServer: ...
|
||||
) -> Server: ...
|
||||
async def create_unix_connection(
|
||||
self,
|
||||
protocol_factory: _ProtocolFactory,
|
||||
@@ -372,7 +374,7 @@ class AbstractEventLoop(metaclass=ABCMeta):
|
||||
sock: Optional[socket] = ...,
|
||||
backlog: int = ...,
|
||||
ssl: _SSLContext = ...,
|
||||
) -> AbstractServer: ...
|
||||
) -> Server: ...
|
||||
@abstractmethod
|
||||
async def create_datagram_endpoint(
|
||||
self,
|
||||
|
||||
@@ -3,6 +3,7 @@ from _typeshed import StrPath
|
||||
from typing import Any, AsyncIterator, Awaitable, Callable, Iterable, Optional, Tuple, Union
|
||||
|
||||
from . import events, protocols, transports
|
||||
from .base_events import Server
|
||||
|
||||
_ClientConnectedCallback = Callable[[StreamReader, StreamWriter], Optional[Awaitable[None]]]
|
||||
|
||||
@@ -33,7 +34,7 @@ async def start_server(
|
||||
limit: int = ...,
|
||||
ssl_handshake_timeout: Optional[float] = ...,
|
||||
**kwds: Any,
|
||||
) -> events.AbstractServer: ...
|
||||
) -> Server: ...
|
||||
|
||||
if sys.platform != "win32":
|
||||
if sys.version_info >= (3, 7):
|
||||
@@ -50,7 +51,7 @@ if sys.platform != "win32":
|
||||
loop: Optional[events.AbstractEventLoop] = ...,
|
||||
limit: int = ...,
|
||||
**kwds: Any,
|
||||
) -> events.AbstractServer: ...
|
||||
) -> Server: ...
|
||||
|
||||
class FlowControlMixin(protocols.Protocol):
|
||||
def __init__(self, loop: Optional[events.AbstractEventLoop] = ...) -> None: ...
|
||||
|
||||
@@ -3,7 +3,8 @@ import types
|
||||
from socket import socket
|
||||
from typing import Any, Callable, Optional, Type, TypeVar
|
||||
|
||||
from .events import AbstractEventLoop, AbstractServer, BaseDefaultEventLoopPolicy, _ProtocolFactory, _SSLContext
|
||||
from .base_events import Server
|
||||
from .events import AbstractEventLoop, BaseDefaultEventLoopPolicy, _ProtocolFactory, _SSLContext
|
||||
from .selector_events import BaseSelectorEventLoop
|
||||
|
||||
_T1 = TypeVar("_T1", bound=AbstractChildWatcher)
|
||||
@@ -41,7 +42,7 @@ class _UnixSelectorEventLoop(BaseSelectorEventLoop):
|
||||
sock: Optional[socket] = ...,
|
||||
backlog: int = ...,
|
||||
ssl: _SSLContext = ...,
|
||||
) -> AbstractServer: ...
|
||||
) -> Server: ...
|
||||
|
||||
class _UnixDefaultEventLoopPolicy(BaseDefaultEventLoopPolicy):
|
||||
def get_child_watcher(self) -> AbstractChildWatcher: ...
|
||||
|
||||
Reference in New Issue
Block a user