diff --git a/stdlib/@tests/test_cases/asyncio/check_create_server.py b/stdlib/@tests/test_cases/asyncio/check_create_server.py new file mode 100644 index 000000000000..8b0adb034269 --- /dev/null +++ b/stdlib/@tests/test_cases/asyncio/check_create_server.py @@ -0,0 +1,12 @@ +from __future__ import annotations + +import asyncio +from collections.abc import Sequence + + +async def check_create_server(loop: asyncio.BaseEventLoop) -> None: + await loop.create_server(asyncio.Protocol, "localhost", None) + await loop.create_server(asyncio.Protocol, ["localhost", "127.0.0.1"], None) + + hosts: Sequence[str] = ["localhost"] + await loop.create_server(asyncio.Protocol, hosts) diff --git a/stdlib/asyncio/base_events.pyi b/stdlib/asyncio/base_events.pyi index 056d9a2d36c9..a1a10e4d6146 100644 --- a/stdlib/asyncio/base_events.pyi +++ b/stdlib/asyncio/base_events.pyi @@ -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, @@ -282,8 +301,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, @@ -297,6 +316,24 @@ 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: AddressFamily = 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, @@ -319,8 +356,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, @@ -333,6 +370,23 @@ 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: AddressFamily = 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, diff --git a/stdlib/asyncio/events.pyi b/stdlib/asyncio/events.pyi index 12978a97679f..868176c92944 100644 --- a/stdlib/asyncio/events.pyi +++ b/stdlib/asyncio/events.pyi @@ -298,8 +298,28 @@ 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, @@ -339,8 +359,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, @@ -355,6 +375,25 @@ class AbstractEventLoop: ) -> Server: ... @overload @abstractmethod + async def create_server( + self, + protocol_factory: _ProtocolFactory, + host: str | Sequence[str], + port: int | None = None, + *, + family: AddressFamily = 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, @@ -378,8 +417,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, @@ -393,6 +432,24 @@ class AbstractEventLoop: ) -> Server: ... @overload @abstractmethod + async def create_server( + self, + protocol_factory: _ProtocolFactory, + host: str | Sequence[str], + port: int | None = None, + *, + family: AddressFamily = 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,