@@ -6,7 +6,7 @@ from collections.abc import Callable, Coroutine, Generator, Sequence
66from contextvars import Context
77from socket import AddressFamily , SocketKind , _Address , _RetAddress , socket
88from typing import IO , Any , Protocol , TypeVar , overload
9- from typing_extensions import Literal , Self , TypeAlias , deprecated
9+ from typing_extensions import Literal , Self , TypeAlias , TypeVarTuple , Unpack , deprecated
1010
1111from . import _AwaitableLike , _CoroutineLike
1212from .base_events import Server
5656 )
5757
5858_T = TypeVar ("_T" )
59+ _Ts = TypeVarTuple ("_Ts" )
5960_ProtocolT = TypeVar ("_ProtocolT" , bound = BaseProtocol )
6061_Context : TypeAlias = dict [str , Any ]
6162_ExceptionHandler : TypeAlias = Callable [[AbstractEventLoop , _Context ], object ]
@@ -131,22 +132,24 @@ class AbstractEventLoop:
131132 # Methods scheduling callbacks. All these return Handles.
132133 if sys .version_info >= (3 , 9 ): # "context" added in 3.9.10/3.10.2
133134 @abstractmethod
134- def call_soon (self , callback : Callable [..., object ], * args : Any , context : Context | None = None ) -> Handle : ...
135+ def call_soon (
136+ self , callback : Callable [[Unpack [_Ts ]], object ], * args : Unpack [_Ts ], context : Context | None = None
137+ ) -> Handle : ...
135138 @abstractmethod
136139 def call_later (
137- self , delay : float , callback : Callable [... , object ], * args : Any , context : Context | None = None
140+ self , delay : float , callback : Callable [[ Unpack [ _Ts ]] , object ], * args : Unpack [ _Ts ] , context : Context | None = None
138141 ) -> TimerHandle : ...
139142 @abstractmethod
140143 def call_at (
141- self , when : float , callback : Callable [... , object ], * args : Any , context : Context | None = None
144+ self , when : float , callback : Callable [[ Unpack [ _Ts ]] , object ], * args : Unpack [ _Ts ] , context : Context | None = None
142145 ) -> TimerHandle : ...
143146 else :
144147 @abstractmethod
145- def call_soon (self , callback : Callable [... , object ], * args : Any ) -> Handle : ...
148+ def call_soon (self , callback : Callable [[ Unpack [ _Ts ]] , object ], * args : Unpack [ _Ts ] ) -> Handle : ...
146149 @abstractmethod
147- def call_later (self , delay : float , callback : Callable [... , object ], * args : Any ) -> TimerHandle : ...
150+ def call_later (self , delay : float , callback : Callable [[ Unpack [ _Ts ]] , object ], * args : Unpack [ _Ts ] ) -> TimerHandle : ...
148151 @abstractmethod
149- def call_at (self , when : float , callback : Callable [... , object ], * args : Any ) -> TimerHandle : ...
152+ def call_at (self , when : float , callback : Callable [[ Unpack [ _Ts ]] , object ], * args : Unpack [ _Ts ] ) -> TimerHandle : ...
150153
151154 @abstractmethod
152155 def time (self ) -> float : ...
@@ -173,13 +176,15 @@ class AbstractEventLoop:
173176 # Methods for interacting with threads
174177 if sys .version_info >= (3 , 9 ): # "context" added in 3.9.10/3.10.2
175178 @abstractmethod
176- def call_soon_threadsafe (self , callback : Callable [..., object ], * args : Any , context : Context | None = None ) -> Handle : ...
179+ def call_soon_threadsafe (
180+ self , callback : Callable [[Unpack [_Ts ]], object ], * args : Unpack [_Ts ], context : Context | None = None
181+ ) -> Handle : ...
177182 else :
178183 @abstractmethod
179- def call_soon_threadsafe (self , callback : Callable [... , object ], * args : Any ) -> Handle : ...
184+ def call_soon_threadsafe (self , callback : Callable [[ Unpack [ _Ts ]] , object ], * args : Unpack [ _Ts ] ) -> Handle : ...
180185
181186 @abstractmethod
182- def run_in_executor (self , executor : Any , func : Callable [... , _T ], * args : Any ) -> Future [_T ]: ...
187+ def run_in_executor (self , executor : Any , func : Callable [[ Unpack [ _Ts ]] , _T ], * args : Unpack [ _Ts ] ) -> Future [_T ]: ...
183188 @abstractmethod
184189 def set_default_executor (self , executor : Any ) -> None : ...
185190 # Network I/O methods returning Futures.
@@ -542,11 +547,11 @@ class AbstractEventLoop:
542547 ** kwargs : Any ,
543548 ) -> tuple [SubprocessTransport , _ProtocolT ]: ...
544549 @abstractmethod
545- def add_reader (self , fd : FileDescriptorLike , callback : Callable [... , Any ], * args : Any ) -> None : ...
550+ def add_reader (self , fd : FileDescriptorLike , callback : Callable [[ Unpack [ _Ts ]] , Any ], * args : Unpack [ _Ts ] ) -> None : ...
546551 @abstractmethod
547552 def remove_reader (self , fd : FileDescriptorLike ) -> bool : ...
548553 @abstractmethod
549- def add_writer (self , fd : FileDescriptorLike , callback : Callable [... , Any ], * args : Any ) -> None : ...
554+ def add_writer (self , fd : FileDescriptorLike , callback : Callable [[ Unpack [ _Ts ]] , Any ], * args : Unpack [ _Ts ] ) -> None : ...
550555 @abstractmethod
551556 def remove_writer (self , fd : FileDescriptorLike ) -> bool : ...
552557 # Completion based I/O methods returning Futures prior to 3.7
@@ -569,7 +574,7 @@ class AbstractEventLoop:
569574 async def sock_sendto (self , sock : socket , data : ReadableBuffer , address : _Address ) -> int : ...
570575 # Signal handling.
571576 @abstractmethod
572- def add_signal_handler (self , sig : int , callback : Callable [... , object ], * args : Any ) -> None : ...
577+ def add_signal_handler (self , sig : int , callback : Callable [[ Unpack [ _Ts ]] , object ], * args : Unpack [ _Ts ] ) -> None : ...
573578 @abstractmethod
574579 def remove_signal_handler (self , sig : int ) -> bool : ...
575580 # Error handlers.
0 commit comments