Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Return concrete server from abstract event loop #5566

Merged
merged 2 commits into from
Jun 3, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
24 changes: 13 additions & 11 deletions stdlib/asyncio/events.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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(
Expand All @@ -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,
Expand All @@ -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,
Expand Down Expand Up @@ -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(
Expand All @@ -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,
Expand All @@ -372,7 +374,7 @@ class AbstractEventLoop(metaclass=ABCMeta):
sock: Optional[socket] = ...,
backlog: int = ...,
ssl: _SSLContext = ...,
) -> AbstractServer: ...
) -> Server: ...
@abstractmethod
async def create_datagram_endpoint(
self,
Expand Down
5 changes: 3 additions & 2 deletions stdlib/asyncio/streams.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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]]]

Expand Down Expand Up @@ -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):
Expand All @@ -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: ...
Expand Down
5 changes: 3 additions & 2 deletions stdlib/asyncio/unix_events.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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: ...
Expand Down