Skip to content

Commit 63489c3

Browse files
authored
asyncio: make AbstractServer abstract and remove unnecessary metaclass=ABCMeta (#7185)
1 parent 5081f68 commit 63489c3

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

stdlib/asyncio/base_events.pyi

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import ssl
22
import sys
33
from _typeshed import FileDescriptorLike
4-
from abc import ABCMeta
54
from asyncio.events import AbstractEventLoop, AbstractServer, Handle, TimerHandle
65
from asyncio.futures import Future
76
from asyncio.protocols import BaseProtocol
@@ -33,6 +32,10 @@ class Server(AbstractServer):
3332
backlog: int,
3433
ssl_handshake_timeout: float | None,
3534
) -> None: ...
35+
def get_loop(self) -> AbstractEventLoop: ...
36+
def is_serving(self) -> bool: ...
37+
async def start_serving(self) -> None: ...
38+
async def serve_forever(self) -> None: ...
3639
else:
3740
def __init__(self, loop: AbstractEventLoop, sockets: list[socket]) -> None: ...
3841
if sys.version_info >= (3, 8):
@@ -43,8 +46,10 @@ class Server(AbstractServer):
4346
def sockets(self) -> list[socket]: ...
4447
else:
4548
sockets: list[socket] | None
49+
def close(self) -> None: ...
50+
async def wait_closed(self) -> None: ...
4651

47-
class BaseEventLoop(AbstractEventLoop, metaclass=ABCMeta):
52+
class BaseEventLoop(AbstractEventLoop):
4853
def run_forever(self) -> None: ...
4954
# Can't use a union, see mypy issue # 1873.
5055
@overload

stdlib/asyncio/events.pyi

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,18 +56,24 @@ class TimerHandle(Handle):
5656
def when(self) -> float: ...
5757

5858
class AbstractServer:
59+
@abstractmethod
5960
def close(self) -> None: ...
6061
if sys.version_info >= (3, 7):
6162
async def __aenter__(self: Self) -> Self: ...
6263
async def __aexit__(self, *exc: Any) -> None: ...
64+
@abstractmethod
6365
def get_loop(self) -> AbstractEventLoop: ...
66+
@abstractmethod
6467
def is_serving(self) -> bool: ...
68+
@abstractmethod
6569
async def start_serving(self) -> None: ...
70+
@abstractmethod
6671
async def serve_forever(self) -> None: ...
6772

73+
@abstractmethod
6874
async def wait_closed(self) -> None: ...
6975

70-
class AbstractEventLoop(metaclass=ABCMeta):
76+
class AbstractEventLoop:
7177
slow_callback_duration: float
7278
@abstractmethod
7379
def run_forever(self) -> None: ...
@@ -491,7 +497,7 @@ class AbstractEventLoop(metaclass=ABCMeta):
491497
@abstractmethod
492498
async def shutdown_default_executor(self) -> None: ...
493499

494-
class AbstractEventLoopPolicy(metaclass=ABCMeta):
500+
class AbstractEventLoopPolicy:
495501
@abstractmethod
496502
def get_event_loop(self) -> AbstractEventLoop: ...
497503
@abstractmethod

0 commit comments

Comments
 (0)