@@ -42,6 +42,7 @@ _T2 = TypeVar("_T2")
42
42
_T3 = TypeVar ("_T3" )
43
43
_T4 = TypeVar ("_T4" )
44
44
_T5 = TypeVar ("_T5" )
45
+ _T6 = TypeVar ("_T6" )
45
46
_FT = TypeVar ("_FT" , bound = Future [Any ])
46
47
_FutureLike : TypeAlias = Future [_T ] | Generator [Any , None , _T ] | Awaitable [_T ]
47
48
_TaskYieldType : TypeAlias = Future [object ] | None
@@ -55,13 +56,13 @@ if sys.version_info >= (3, 10):
55
56
56
57
else :
57
58
def as_completed (
58
- fs : Iterable [_FutureLike [_T ]], * , loop : AbstractEventLoop | None = None , timeout : float | None = None
59
+ fs : Iterable [_FutureLike [_T ]], * , loop : AbstractEventLoop | None = ... , timeout : float | None = ...
59
60
) -> Iterator [Future [_T ]]: ...
60
61
61
62
@overload
62
- def ensure_future (coro_or_future : _FT , * , loop : AbstractEventLoop | None = None ) -> _FT : ... # type: ignore[misc]
63
+ def ensure_future (coro_or_future : _FT , * , loop : AbstractEventLoop | None = ... ) -> _FT : ... # type: ignore[misc]
63
64
@overload
64
- def ensure_future (coro_or_future : Awaitable [_T ], * , loop : AbstractEventLoop | None = None ) -> Task [_T ]: ...
65
+ def ensure_future (coro_or_future : Awaitable [_T ], * , loop : AbstractEventLoop | None = ... ) -> Task [_T ]: ...
65
66
66
67
# `gather()` actually returns a list with length equal to the number
67
68
# of tasks passed; however, Tuple is used similar to the annotation for
@@ -72,18 +73,21 @@ def ensure_future(coro_or_future: Awaitable[_T], *, loop: AbstractEventLoop | No
72
73
# but having overlapping overloads is the only way to get acceptable type inference in all edge cases.
73
74
if sys .version_info >= (3 , 10 ):
74
75
@overload
75
- def gather (__coro_or_future1 : _FutureLike [_T1 ], * , return_exceptions : Literal [False ] = False ) -> Future [tuple [_T1 ]]: ... # type: ignore[misc]
76
+ def gather (__coro_or_future1 : _FutureLike [_T1 ], * , return_exceptions : Literal [False ] = ... ) -> Future [tuple [_T1 ]]: ... # type: ignore[misc]
76
77
@overload
77
78
def gather ( # type: ignore[misc]
78
- __coro_or_future1 : _FutureLike [_T1 ], __coro_or_future2 : _FutureLike [_T2 ], * , return_exceptions : Literal [False ] = False
79
+ __coro_or_future1 : _FutureLike [_T1 ],
80
+ __coro_or_future2 : _FutureLike [_T2 ],
81
+ * ,
82
+ return_exceptions : Literal [False ] = ...,
79
83
) -> Future [tuple [_T1 , _T2 ]]: ...
80
84
@overload
81
85
def gather ( # type: ignore[misc]
82
86
__coro_or_future1: _FutureLike [_T1 ],
83
87
__coro_or_future2 : _FutureLike [_T2 ],
84
88
__coro_or_future3 : _FutureLike [_T3 ],
85
89
* ,
86
- return_exceptions : Literal [False ] = False ,
90
+ return_exceptions : Literal [False ] = ... ,
87
91
) -> Future [tuple [_T1 , _T2 , _T3 ]]: ...
88
92
@overload
89
93
def gather ( # type: ignore[misc]
@@ -92,7 +96,7 @@ if sys.version_info >= (3, 10):
92
96
__coro_or_future3 : _FutureLike [_T3 ],
93
97
__coro_or_future4 : _FutureLike [_T4 ],
94
98
* ,
95
- return_exceptions : Literal [False ] = False ,
99
+ return_exceptions : Literal [False ] = ... ,
96
100
) -> Future [tuple [_T1 , _T2 , _T3 , _T4 ]]: ...
97
101
@overload
98
102
def gather ( # type: ignore[misc]
@@ -102,8 +106,19 @@ if sys.version_info >= (3, 10):
102
106
__coro_or_future4 : _FutureLike [_T4 ],
103
107
__coro_or_future5 : _FutureLike [_T5 ],
104
108
* ,
105
- return_exceptions : Literal [False ] = False ,
109
+ return_exceptions : Literal [False ] = ... ,
106
110
) -> Future [tuple [_T1 , _T2 , _T3 , _T4 , _T5 ]]: ...
111
+ @overload
112
+ def gather ( # type: ignore[misc]
113
+ __coro_or_future1 : _FutureLike [_T1 ],
114
+ __coro_or_future2 : _FutureLike [_T2 ],
115
+ __coro_or_future3 : _FutureLike [_T3 ],
116
+ __coro_or_future4 : _FutureLike [_T4 ],
117
+ __coro_or_future5 : _FutureLike [_T5 ],
118
+ __coro_or_future6 : _FutureLike [_T6 ],
119
+ * ,
120
+ return_exceptions : Literal [False ] = ...,
121
+ ) -> Future [tuple [_T1 , _T2 , _T3 , _T4 , _T5 , _T6 ]]: ...
107
122
@overload
108
123
def gather (* coros_or_futures : _FutureLike [_T ], return_exceptions : Literal [False ] = False ) -> Future [list [_T ]]: ... # type: ignore[misc]
109
124
@overload
@@ -136,35 +151,39 @@ if sys.version_info >= (3, 10):
136
151
__coro_or_future3 : _FutureLike [_T3 ],
137
152
__coro_or_future4 : _FutureLike [_T4 ],
138
153
__coro_or_future5 : _FutureLike [_T5 ],
154
+ __coro_or_future6 : _FutureLike [_T6 ],
139
155
* ,
140
156
return_exceptions : bool ,
141
157
) -> Future [
142
- tuple [_T1 | BaseException , _T2 | BaseException , _T3 | BaseException , _T4 | BaseException , _T5 | BaseException ]
158
+ tuple [_T1 | BaseException , _T2 | BaseException , _T3 | BaseException , _T4 | BaseException , _T5 | BaseException , _T6 | BaseException ]
143
159
]: ...
144
160
@overload
145
- def gather (* coros_or_futures : _FutureLike [Any ], return_exceptions : bool = False ) -> Future [list [Any ]]: ... # type: ignore[misc]
161
+ def gather (* coros_or_futures : _FutureLike [_T ], return_exceptions : bool = ... ) -> Future [list [_T | BaseException ]]: ... # type: ignore[misc]
146
162
147
163
else :
148
164
@overload
149
165
def gather ( # type: ignore[misc]
150
- __coro_or_future1 : _FutureLike [_T1 ], * , loop : AbstractEventLoop | None = None , return_exceptions : Literal [False ] = False
166
+ __coro_or_future1 : _FutureLike [_T1 ],
167
+ * ,
168
+ loop : AbstractEventLoop | None = ...,
169
+ return_exceptions : Literal [False ] = ...,
151
170
) -> Future [tuple [_T1 ]]: ...
152
171
@overload
153
172
def gather ( # type: ignore[misc]
154
173
__coro_or_future1 : _FutureLike [_T1 ],
155
174
__coro_or_future2 : _FutureLike [_T2 ],
156
175
* ,
157
- loop : AbstractEventLoop | None = None ,
158
- return_exceptions : Literal [False ] = False ,
176
+ loop : AbstractEventLoop | None = ... ,
177
+ return_exceptions : Literal [False ] = ... ,
159
178
) -> Future [tuple [_T1 , _T2 ]]: ...
160
179
@overload
161
180
def gather ( # type: ignore[misc]
162
181
__coro_or_future1 : _FutureLike [_T1 ],
163
182
__coro_or_future2 : _FutureLike [_T2 ],
164
183
__coro_or_future3 : _FutureLike [_T3 ],
165
184
* ,
166
- loop : AbstractEventLoop | None = None ,
167
- return_exceptions : Literal [False ] = False ,
185
+ loop : AbstractEventLoop | None = ... ,
186
+ return_exceptions : Literal [False ] = ... ,
168
187
) -> Future [tuple [_T1 , _T2 , _T3 ]]: ...
169
188
@overload
170
189
def gather ( # type: ignore[misc]
@@ -173,8 +192,8 @@ else:
173
192
__coro_or_future3 : _FutureLike [_T3 ],
174
193
__coro_or_future4 : _FutureLike [_T4 ],
175
194
* ,
176
- loop : AbstractEventLoop | None = None ,
177
- return_exceptions : Literal [False ] = False ,
195
+ loop : AbstractEventLoop | None = ... ,
196
+ return_exceptions : Literal [False ] = ... ,
178
197
) -> Future [tuple [_T1 , _T2 , _T3 , _T4 ]]: ...
179
198
@overload
180
199
def gather ( # type: ignore[misc]
@@ -184,23 +203,21 @@ else:
184
203
__coro_or_future4 : _FutureLike [_T4 ],
185
204
__coro_or_future5 : _FutureLike [_T5 ],
186
205
* ,
187
- loop : AbstractEventLoop | None = None ,
188
- return_exceptions : Literal [False ] = False ,
206
+ loop : AbstractEventLoop | None = ... ,
207
+ return_exceptions : Literal [False ] = ... ,
189
208
) -> Future [tuple [_T1 , _T2 , _T3 , _T4 , _T5 ]]: ...
190
209
@overload
191
- def gather ( # type: ignore[misc]
192
- * coros_or_futures : _FutureLike [_T ], loop : AbstractEventLoop | None = None , return_exceptions : Literal [False ] = False
193
- ) -> Future [list [_T ]]: ...
210
+ def gather (* coros_or_futures : _FutureLike [_T ], return_exceptions : Literal [False ] = False ) -> Future [list [_T ]]: ... # type: ignore[misc]
194
211
@overload
195
212
def gather ( # type: ignore[misc]
196
- __coro_or_future1 : _FutureLike [_T1 ], * , loop : AbstractEventLoop | None = None , return_exceptions : bool
213
+ __coro_or_future1 : _FutureLike [_T1 ], * , loop : AbstractEventLoop | None = ... , return_exceptions : bool
197
214
) -> Future [tuple [_T1 | BaseException ]]: ...
198
215
@overload
199
216
def gather ( # type: ignore[misc]
200
217
__coro_or_future1 : _FutureLike [_T1 ],
201
218
__coro_or_future2 : _FutureLike [_T2 ],
202
219
* ,
203
- loop : AbstractEventLoop | None = None ,
220
+ loop : AbstractEventLoop | None = ... ,
204
221
return_exceptions : bool ,
205
222
) -> Future [tuple [_T1 | BaseException , _T2 | BaseException ]]: ...
206
223
@overload
@@ -209,7 +226,7 @@ else:
209
226
__coro_or_future2 : _FutureLike [_T2 ],
210
227
__coro_or_future3 : _FutureLike [_T3 ],
211
228
* ,
212
- loop : AbstractEventLoop | None = None ,
229
+ loop : AbstractEventLoop | None = ... ,
213
230
return_exceptions : bool ,
214
231
) -> Future [tuple [_T1 | BaseException , _T2 | BaseException , _T3 | BaseException ]]: ...
215
232
@overload
@@ -219,7 +236,7 @@ else:
219
236
__coro_or_future3 : _FutureLike [_T3 ],
220
237
__coro_or_future4 : _FutureLike [_T4 ],
221
238
* ,
222
- loop : AbstractEventLoop | None = None ,
239
+ loop : AbstractEventLoop | None = ... ,
223
240
return_exceptions : bool ,
224
241
) -> Future [tuple [_T1 | BaseException , _T2 | BaseException , _T3 | BaseException , _T4 | BaseException ]]: ...
225
242
@overload
@@ -230,15 +247,28 @@ else:
230
247
__coro_or_future4 : _FutureLike [_T4 ],
231
248
__coro_or_future5 : _FutureLike [_T5 ],
232
249
* ,
233
- loop : AbstractEventLoop | None = None ,
250
+ loop : AbstractEventLoop | None = ... ,
234
251
return_exceptions : bool ,
235
252
) -> Future [
236
253
tuple [_T1 | BaseException , _T2 | BaseException , _T3 | BaseException , _T4 | BaseException , _T5 | BaseException ]
254
+ ]: ...
255
+ @overload
256
+ def gather ( # type: ignore[misc]
257
+ __coro_or_future1 : _FutureLike [_T1 ],
258
+ __coro_or_future2 : _FutureLike [_T2 ],
259
+ __coro_or_future3 : _FutureLike [_T3 ],
260
+ __coro_or_future4 : _FutureLike [_T4 ],
261
+ __coro_or_future5 : _FutureLike [_T5 ],
262
+ __coro_or_future6 : _FutureLike [_T6 ],
263
+ * ,
264
+ return_exceptions : bool ,
265
+ ) -> Future [
266
+ tuple [_T1 | BaseException , _T2 | BaseException , _T3 | BaseException , _T4 | BaseException , _T5 | BaseException , _T6 | BaseException ]
237
267
]: ...
238
268
@overload
239
269
def gather ( # type: ignore[misc]
240
- * coros_or_futures : _FutureLike [Any ], loop : AbstractEventLoop | None = None , return_exceptions : bool = False
241
- ) -> Future [list [Any ]]: ...
270
+ * coros_or_futures : _FutureLike [T ], loop : AbstractEventLoop | None = ... , return_exceptions : bool = ...
271
+ ) -> Future [list [T | BaseException ]]: ...
242
272
243
273
def run_coroutine_threadsafe (coro : _FutureLike [_T ], loop : AbstractEventLoop ) -> concurrent .futures .Future [_T ]: ...
244
274
@@ -249,36 +279,32 @@ if sys.version_info >= (3, 10):
249
279
@overload
250
280
async def sleep (delay : float , result : _T ) -> _T : ...
251
281
@overload
252
- async def wait (fs : Iterable [_FT ], * , timeout : float | None = None , return_when : str = "ALL_COMPLETED" ) -> tuple [set [_FT ], set [_FT ]]: ... # type: ignore[misc]
282
+ async def wait (fs : Iterable [_FT ], * , timeout : float | None = ... , return_when : str = ... ) -> tuple [set [_FT ], set [_FT ]]: ... # type: ignore[misc]
253
283
@overload
254
284
async def wait (
255
- fs : Iterable [Awaitable [_T ]], * , timeout : float | None = None , return_when : str = "ALL_COMPLETED"
285
+ fs : Iterable [Awaitable [_T ]], * , timeout : float | None = ... , return_when : str = ...
256
286
) -> tuple [set [Task [_T ]], set [Task [_T ]]]: ...
257
287
async def wait_for (fut : _FutureLike [_T ], timeout : float | None ) -> _T : ...
258
288
259
289
else :
260
- def shield (arg : _FutureLike [_T ], * , loop : AbstractEventLoop | None = None ) -> Future [_T ]: ...
290
+ def shield (arg : _FutureLike [_T ], * , loop : AbstractEventLoop | None = ... ) -> Future [_T ]: ...
261
291
@overload
262
- async def sleep (delay : float , * , loop : AbstractEventLoop | None = None ) -> None : ...
292
+ async def sleep (delay : float , * , loop : AbstractEventLoop | None = ... ) -> None : ...
263
293
@overload
264
- async def sleep (delay : float , result : _T , * , loop : AbstractEventLoop | None = None ) -> _T : ...
294
+ async def sleep (delay : float , result : _T , * , loop : AbstractEventLoop | None = ... ) -> _T : ...
265
295
@overload
266
296
async def wait ( # type: ignore[misc]
267
- fs : Iterable [_FT ],
268
- * ,
269
- loop : AbstractEventLoop | None = None ,
270
- timeout : float | None = None ,
271
- return_when : str = "ALL_COMPLETED" ,
297
+ fs : Iterable [_FT ], * , loop : AbstractEventLoop | None = ..., timeout : float | None = ..., return_when : str = ...
272
298
) -> tuple [set [_FT ], set [_FT ]]: ...
273
299
@overload
274
300
async def wait (
275
301
fs : Iterable [Awaitable [_T ]],
276
302
* ,
277
- loop : AbstractEventLoop | None = None ,
278
- timeout : float | None = None ,
279
- return_when : str = "ALL_COMPLETED" ,
303
+ loop : AbstractEventLoop | None = ... ,
304
+ timeout : float | None = ... ,
305
+ return_when : str = ... ,
280
306
) -> tuple [set [Task [_T ]], set [Task [_T ]]]: ...
281
- async def wait_for (fut : _FutureLike [_T ], timeout : float | None , * , loop : AbstractEventLoop | None = None ) -> _T : ...
307
+ async def wait_for (fut : _FutureLike [_T ], timeout : float | None , * , loop : AbstractEventLoop | None = ... ) -> _T : ...
282
308
283
309
# mypy and pyright complain that a subclass of an invariant class shouldn't be covariant.
284
310
# While this is true in general, here it's sort-of okay to have a covariant subclass,
@@ -309,21 +335,26 @@ class Task(Future[_T_co], Generic[_T_co]): # type: ignore[type-var] # pyright:
309
335
def uncancel (self ) -> int : ...
310
336
if sys .version_info < (3 , 9 ):
311
337
@classmethod
312
- def current_task (cls , loop : AbstractEventLoop | None = None ) -> Task [Any ] | None : ...
338
+ def current_task (cls , loop : AbstractEventLoop | None = ... ) -> Task [Any ] | None : ...
313
339
@classmethod
314
- def all_tasks (cls , loop : AbstractEventLoop | None = None ) -> set [Task [Any ]]: ...
340
+ def all_tasks (cls , loop : AbstractEventLoop | None = ... ) -> set [Task [Any ]]: ...
315
341
if sys .version_info >= (3 , 9 ):
316
342
def __class_getitem__ (cls , item : Any ) -> GenericAlias : ...
317
343
318
344
def all_tasks (loop : AbstractEventLoop | None = None ) -> set [Task [Any ]]: ...
319
345
320
346
if sys .version_info >= (3 , 11 ):
321
347
def create_task (
322
- coro : Generator [Any , None , _T ] | Coroutine [Any , Any , _T ], * , name : str | None = None , context : Context | None = None
348
+ coro : Generator [Any , None , _T ] | Coroutine [Any , Any , _T ],
349
+ * ,
350
+ name : str | None = None ,
351
+ context : Context | None = None ,
323
352
) -> Task [_T ]: ...
324
353
325
354
elif sys .version_info >= (3 , 8 ):
326
- def create_task (coro : Generator [Any , None , _T ] | Coroutine [Any , Any , _T ], * , name : str | None = None ) -> Task [_T ]: ...
355
+ def create_task (
356
+ coro : Generator [Any , None , _T ] | Coroutine [Any , Any , _T ], * , name : str | None = ...
357
+ ) -> Task [_T ]: ...
327
358
328
359
else :
329
360
def create_task (coro : Generator [Any , None , _T ] | Coroutine [Any , Any , _T ]) -> Task [_T ]: ...
0 commit comments