Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions stdlib/@tests/test_cases/asyncio/check_create_server.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import asyncio
import socket


async def check_abstract_event_loop(loop: asyncio.AbstractEventLoop, sock: socket.socket) -> None:
await loop.create_server(asyncio.Protocol, None, 8000)
await loop.create_server(asyncio.Protocol, "localhost")
await loop.create_server(asyncio.Protocol, "localhost", None)
await loop.create_server(asyncio.Protocol, "localhost", 8000)
await loop.create_server(asyncio.Protocol, port=8000)
await loop.create_server(asyncio.Protocol, sock=sock)

await loop.create_server(asyncio.Protocol) # type: ignore
await loop.create_server(asyncio.Protocol, "localhost", sock=sock) # type: ignore


async def check_base_event_loop(loop: asyncio.BaseEventLoop, sock: socket.socket) -> None:
await loop.create_server(asyncio.Protocol, None, 8000)
await loop.create_server(asyncio.Protocol, "localhost")
await loop.create_server(asyncio.Protocol, "localhost", None)
await loop.create_server(asyncio.Protocol, "localhost", 8000)
await loop.create_server(asyncio.Protocol, port=8000)
await loop.create_server(asyncio.Protocol, sock=sock)

await loop.create_server(asyncio.Protocol) # type: ignore
await loop.create_server(asyncio.Protocol, "localhost", sock=sock) # type: ignore
126 changes: 117 additions & 9 deletions stdlib/asyncio/base_events.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -243,8 +243,27 @@ class BaseEventLoop(AbstractEventLoop):
async def create_server(
self,
protocol_factory: _ProtocolFactory,
host: str | Sequence[str] | None = None,
port: int = ...,
host: str | Sequence[str] | None,
port: int,
*,
family: int = 0,
flags: int = 1,
sock: None = None,
backlog: int = 100,
ssl: _SSLContext = None,
reuse_address: bool | None = None,
reuse_port: bool | None = None,
keep_alive: bool | None = None,
ssl_handshake_timeout: float | None = None,
ssl_shutdown_timeout: float | None = None,
start_serving: bool = True,
) -> Server: ...
@overload
async def create_server(
self,
protocol_factory: _ProtocolFactory,
host: str | Sequence[str],
port: int | None = None,
*,
family: int = 0,
flags: int = 1,
Expand All @@ -259,6 +278,25 @@ class BaseEventLoop(AbstractEventLoop):
start_serving: bool = True,
) -> Server: ...
@overload
async def create_server(
self,
protocol_factory: _ProtocolFactory,
host: None = None,
*,
port: int,
family: int = 0,
flags: int = 1,
sock: None = None,
backlog: int = 100,
ssl: _SSLContext = None,
reuse_address: bool | None = None,
reuse_port: bool | None = None,
keep_alive: bool | None = None,
ssl_handshake_timeout: float | None = None,
ssl_shutdown_timeout: float | None = None,
start_serving: bool = True,
) -> Server: ...
@overload
async def create_server(
self,
protocol_factory: _ProtocolFactory,
Expand All @@ -267,7 +305,7 @@ class BaseEventLoop(AbstractEventLoop):
*,
family: int = 0,
flags: int = 1,
sock: socket = ...,
sock: socket,
backlog: int = 100,
ssl: _SSLContext = None,
reuse_address: bool | None = None,
Expand All @@ -282,8 +320,8 @@ class BaseEventLoop(AbstractEventLoop):
async def create_server(
self,
protocol_factory: _ProtocolFactory,
host: str | Sequence[str] | None = None,
port: int = ...,
host: str | Sequence[str] | None,
port: int,
*,
family: int = AddressFamily.AF_UNSPEC,
flags: int = AddressInfo.AI_PASSIVE,
Expand All @@ -297,6 +335,42 @@ class BaseEventLoop(AbstractEventLoop):
start_serving: bool = True,
) -> Server: ...
@overload
async def create_server(
self,
protocol_factory: _ProtocolFactory,
host: str | Sequence[str],
port: int | None = None,
*,
family: int = AddressFamily.AF_UNSPEC,
flags: int = AddressInfo.AI_PASSIVE,
sock: None = None,
backlog: int = 100,
ssl: _SSLContext = None,
reuse_address: bool | None = None,
reuse_port: bool | None = None,
ssl_handshake_timeout: float | None = None,
ssl_shutdown_timeout: float | None = None,
start_serving: bool = True,
) -> Server: ...
@overload
async def create_server(
self,
protocol_factory: _ProtocolFactory,
host: None = None,
*,
port: int,
family: int = AddressFamily.AF_UNSPEC,
flags: int = AddressInfo.AI_PASSIVE,
sock: None = None,
backlog: int = 100,
ssl: _SSLContext = None,
reuse_address: bool | None = None,
reuse_port: bool | None = None,
ssl_handshake_timeout: float | None = None,
ssl_shutdown_timeout: float | None = None,
start_serving: bool = True,
) -> Server: ...
@overload
async def create_server(
self,
protocol_factory: _ProtocolFactory,
Expand All @@ -305,7 +379,7 @@ class BaseEventLoop(AbstractEventLoop):
*,
family: int = AddressFamily.AF_UNSPEC,
flags: int = AddressInfo.AI_PASSIVE,
sock: socket = ...,
sock: socket,
backlog: int = 100,
ssl: _SSLContext = None,
reuse_address: bool | None = None,
Expand All @@ -319,9 +393,43 @@ class BaseEventLoop(AbstractEventLoop):
async def create_server(
self,
protocol_factory: _ProtocolFactory,
host: str | Sequence[str] | None = None,
port: int = ...,
host: str | Sequence[str] | None,
port: int,
*,
family: int = AddressFamily.AF_UNSPEC,
flags: int = AddressInfo.AI_PASSIVE,
sock: None = None,
backlog: int = 100,
ssl: _SSLContext = None,
reuse_address: bool | None = None,
reuse_port: bool | None = None,
ssl_handshake_timeout: float | None = None,
start_serving: bool = True,
) -> Server: ...
@overload
async def create_server(
self,
protocol_factory: _ProtocolFactory,
host: str | Sequence[str],
port: int | None = None,
*,
family: int = AddressFamily.AF_UNSPEC,
flags: int = AddressInfo.AI_PASSIVE,
sock: None = None,
backlog: int = 100,
ssl: _SSLContext = None,
reuse_address: bool | None = None,
reuse_port: bool | None = None,
ssl_handshake_timeout: float | None = None,
start_serving: bool = True,
) -> Server: ...
@overload
async def create_server(
self,
protocol_factory: _ProtocolFactory,
host: None = None,
*,
port: int,
family: int = AddressFamily.AF_UNSPEC,
flags: int = AddressInfo.AI_PASSIVE,
sock: None = None,
Expand All @@ -341,7 +449,7 @@ class BaseEventLoop(AbstractEventLoop):
*,
family: int = AddressFamily.AF_UNSPEC,
flags: int = AddressInfo.AI_PASSIVE,
sock: socket = ...,
sock: socket,
backlog: int = 100,
ssl: _SSLContext = None,
reuse_address: bool | None = None,
Expand Down
132 changes: 123 additions & 9 deletions stdlib/asyncio/events.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -298,9 +298,49 @@ class AbstractEventLoop:
async def create_server(
self,
protocol_factory: _ProtocolFactory,
host: str | Sequence[str] | None = None,
port: int = ...,
host: str | Sequence[str] | None,
port: int,
*,
family: int = AddressFamily.AF_UNSPEC,
flags: int = AddressInfo.AI_PASSIVE,
sock: None = None,
backlog: int = 100,
ssl: _SSLContext = None,
reuse_address: bool | None = None,
reuse_port: bool | None = None,
keep_alive: bool | None = None,
ssl_handshake_timeout: float | None = None,
ssl_shutdown_timeout: float | None = None,
start_serving: bool = True,
) -> Server: ...
@overload
@abstractmethod
async def create_server(
self,
protocol_factory: _ProtocolFactory,
host: str | Sequence[str],
port: int | None = None,
*,
family: int = AddressFamily.AF_UNSPEC,
flags: int = AddressInfo.AI_PASSIVE,
sock: None = None,
backlog: int = 100,
ssl: _SSLContext = None,
reuse_address: bool | None = None,
reuse_port: bool | None = None,
keep_alive: bool | None = None,
ssl_handshake_timeout: float | None = None,
ssl_shutdown_timeout: float | None = None,
start_serving: bool = True,
) -> Server: ...
@overload
@abstractmethod
async def create_server(
self,
protocol_factory: _ProtocolFactory,
host: None = None,
*,
port: int,
family: int = AddressFamily.AF_UNSPEC,
flags: int = AddressInfo.AI_PASSIVE,
sock: None = None,
Expand All @@ -323,7 +363,7 @@ class AbstractEventLoop:
*,
family: int = AddressFamily.AF_UNSPEC,
flags: int = AddressInfo.AI_PASSIVE,
sock: socket = ...,
sock: socket,
backlog: int = 100,
ssl: _SSLContext = None,
reuse_address: bool | None = None,
Expand All @@ -339,8 +379,8 @@ class AbstractEventLoop:
async def create_server(
self,
protocol_factory: _ProtocolFactory,
host: str | Sequence[str] | None = None,
port: int = ...,
host: str | Sequence[str] | None,
port: int,
*,
family: int = AddressFamily.AF_UNSPEC,
flags: int = AddressInfo.AI_PASSIVE,
Expand All @@ -355,6 +395,44 @@ class AbstractEventLoop:
) -> Server: ...
@overload
@abstractmethod
async def create_server(
self,
protocol_factory: _ProtocolFactory,
host: str | Sequence[str],
port: int | None = None,
*,
family: int = AddressFamily.AF_UNSPEC,
flags: int = AddressInfo.AI_PASSIVE,
sock: None = None,
backlog: int = 100,
ssl: _SSLContext = None,
reuse_address: bool | None = None,
reuse_port: bool | None = None,
ssl_handshake_timeout: float | None = None,
ssl_shutdown_timeout: float | None = None,
start_serving: bool = True,
) -> Server: ...
@overload
@abstractmethod
async def create_server(
self,
protocol_factory: _ProtocolFactory,
host: None = None,
*,
port: int,
family: int = AddressFamily.AF_UNSPEC,
flags: int = AddressInfo.AI_PASSIVE,
sock: None = None,
backlog: int = 100,
ssl: _SSLContext = None,
reuse_address: bool | None = None,
reuse_port: bool | None = None,
ssl_handshake_timeout: float | None = None,
ssl_shutdown_timeout: float | None = None,
start_serving: bool = True,
) -> Server: ...
@overload
@abstractmethod
async def create_server(
self,
protocol_factory: _ProtocolFactory,
Expand All @@ -363,7 +441,7 @@ class AbstractEventLoop:
*,
family: int = AddressFamily.AF_UNSPEC,
flags: int = AddressInfo.AI_PASSIVE,
sock: socket = ...,
sock: socket,
backlog: int = 100,
ssl: _SSLContext = None,
reuse_address: bool | None = None,
Expand All @@ -378,8 +456,26 @@ class AbstractEventLoop:
async def create_server(
self,
protocol_factory: _ProtocolFactory,
host: str | Sequence[str] | None = None,
port: int = ...,
host: str | Sequence[str] | None,
port: int,
*,
family: int = AddressFamily.AF_UNSPEC,
flags: int = AddressInfo.AI_PASSIVE,
sock: None = None,
backlog: int = 100,
ssl: _SSLContext = None,
reuse_address: bool | None = None,
reuse_port: bool | None = None,
ssl_handshake_timeout: float | None = None,
start_serving: bool = True,
) -> Server: ...
@overload
@abstractmethod
async def create_server(
self,
protocol_factory: _ProtocolFactory,
host: str | Sequence[str],
port: int | None = None,
*,
family: int = AddressFamily.AF_UNSPEC,
flags: int = AddressInfo.AI_PASSIVE,
Expand All @@ -393,6 +489,24 @@ class AbstractEventLoop:
) -> Server: ...
@overload
@abstractmethod
async def create_server(
self,
protocol_factory: _ProtocolFactory,
host: None = None,
*,
port: int,
family: int = AddressFamily.AF_UNSPEC,
flags: int = AddressInfo.AI_PASSIVE,
sock: None = None,
backlog: int = 100,
ssl: _SSLContext = None,
reuse_address: bool | None = None,
reuse_port: bool | None = None,
ssl_handshake_timeout: float | None = None,
start_serving: bool = True,
) -> Server: ...
@overload
@abstractmethod
async def create_server(
self,
protocol_factory: _ProtocolFactory,
Expand All @@ -401,7 +515,7 @@ class AbstractEventLoop:
*,
family: int = AddressFamily.AF_UNSPEC,
flags: int = AddressInfo.AI_PASSIVE,
sock: socket = ...,
sock: socket,
backlog: int = 100,
ssl: _SSLContext = None,
reuse_address: bool | None = None,
Expand Down