1
1
from __future__ import annotations
2
2
3
3
import socket
4
- from abc import ABCMeta , abstractmethod
4
+ from abc import ABC , abstractmethod
5
5
from typing import TYPE_CHECKING , Generic , TypeVar
6
6
7
7
import trio
16
16
from .lowlevel import Task
17
17
18
18
19
- # We use ABCMeta instead of ABC, plus set __slots__=(), so as not to force a
20
- # __dict__ onto subclasses.
21
- class Clock (metaclass = ABCMeta ):
19
+ class Clock (ABC ):
22
20
"""The interface for custom run loop clocks."""
23
21
24
22
__slots__ = ()
@@ -68,7 +66,7 @@ def deadline_to_sleep_time(self, deadline: float) -> float:
68
66
"""
69
67
70
68
71
- class Instrument (metaclass = ABCMeta ): # noqa: B024 # conceptually is ABC
69
+ class Instrument (ABC ): # noqa: B024 # conceptually is ABC
72
70
"""The interface for run loop instrumentation.
73
71
74
72
Instruments don't have to inherit from this abstract base class, and all
@@ -155,7 +153,7 @@ def after_io_wait(self, timeout: float) -> None:
155
153
return
156
154
157
155
158
- class HostnameResolver (metaclass = ABCMeta ):
156
+ class HostnameResolver (ABC ):
159
157
"""If you have a custom hostname resolver, then implementing
160
158
:class:`HostnameResolver` allows you to register this to be used by Trio.
161
159
@@ -209,14 +207,16 @@ async def getnameinfo(
209
207
"""
210
208
211
209
212
- class SocketFactory (metaclass = ABCMeta ):
210
+ class SocketFactory (ABC ):
213
211
"""If you write a custom class implementing the Trio socket interface,
214
212
then you can use a :class:`SocketFactory` to get Trio to use it.
215
213
216
214
See :func:`trio.socket.set_custom_socket_factory`.
217
215
218
216
"""
219
217
218
+ __slots__ = ()
219
+
220
220
@abstractmethod
221
221
def socket (
222
222
self ,
@@ -240,7 +240,7 @@ def socket(
240
240
"""
241
241
242
242
243
- class AsyncResource (metaclass = ABCMeta ):
243
+ class AsyncResource (ABC ):
244
244
"""A standard interface for resources that needs to be cleaned up, and
245
245
where that cleanup may require blocking operations.
246
246
@@ -698,3 +698,5 @@ class Channel(SendChannel[T], ReceiveChannel[T]):
698
698
`ReceiveChannel` interfaces, so you can both send and receive objects.
699
699
700
700
"""
701
+
702
+ __slots__ = ()
0 commit comments