@@ -66,25 +66,26 @@ def ensure_future(coro_or_future: Awaitable[_T], *, loop: AbstractEventLoop | No
66
66
# of tasks passed; however, Tuple is used similar to the annotation for
67
67
# zip() because typing does not support variadic type variables. See
68
68
# typing PR #1550 for discussion.
69
+ #
70
+ # The many type: ignores here are because the overloads overlap,
71
+ # but having overlapping overloads is the only way to get acceptable type inference in all edge cases.
69
72
if sys .version_info >= (3 , 10 ):
70
73
@overload
71
- def gather (* , return_exceptions : bool = ...) -> Future [tuple [() ]]: ...
74
+ def gather (__coro_or_future1 : _FutureLike [ _T1 ], * , return_exceptions : Literal [ False ] = ...) -> Future [tuple [_T1 ]]: ... # type: ignore[misc]
72
75
@overload
73
- def gather (__coro_or_future1 : _FutureLike [_T1 ], * , return_exceptions : Literal [False ] = ...) -> Future [tuple [_T1 ]]: ...
74
- @overload
75
- def gather (
76
+ def gather ( # type: ignore[misc]
76
77
__coro_or_future1 : _FutureLike [_T1 ], __coro_or_future2 : _FutureLike [_T2 ], * , return_exceptions : Literal [False ] = ...
77
78
) -> Future [tuple [_T1 , _T2 ]]: ...
78
79
@overload
79
- def gather (
80
+ def gather ( # type: ignore[misc]
80
81
__coro_or_future1 : _FutureLike [_T1 ],
81
82
__coro_or_future2 : _FutureLike [_T2 ],
82
83
__coro_or_future3 : _FutureLike [_T3 ],
83
84
* ,
84
85
return_exceptions : Literal [False ] = ...,
85
86
) -> Future [tuple [_T1 , _T2 , _T3 ]]: ...
86
87
@overload
87
- def gather (
88
+ def gather ( # type: ignore[misc]
88
89
__coro_or_future1 : _FutureLike [_T1 ],
89
90
__coro_or_future2 : _FutureLike [_T2 ],
90
91
__coro_or_future3 : _FutureLike [_T3 ],
@@ -93,7 +94,7 @@ if sys.version_info >= (3, 10):
93
94
return_exceptions : Literal [False ] = ...,
94
95
) -> Future [tuple [_T1 , _T2 , _T3 , _T4 ]]: ...
95
96
@overload
96
- def gather (
97
+ def gather ( # type: ignore[misc]
97
98
__coro_or_future1 : _FutureLike [_T1 ],
98
99
__coro_or_future2 : _FutureLike [_T2 ],
99
100
__coro_or_future3 : _FutureLike [_T3 ],
@@ -103,21 +104,21 @@ if sys.version_info >= (3, 10):
103
104
return_exceptions : Literal [False ] = ...,
104
105
) -> Future [tuple [_T1 , _T2 , _T3 , _T4 , _T5 ]]: ...
105
106
@overload
106
- def gather (__coro_or_future1 : _FutureLike [_T1 ], * , return_exceptions : bool ) -> Future [tuple [_T1 | BaseException ]]: ...
107
+ def gather (__coro_or_future1 : _FutureLike [_T1 ], * , return_exceptions : bool ) -> Future [tuple [_T1 | BaseException ]]: ... # type: ignore[misc]
107
108
@overload
108
- def gather (
109
+ def gather ( # type: ignore[misc]
109
110
__coro_or_future1 : _FutureLike [_T1 ], __coro_or_future2 : _FutureLike [_T2 ], * , return_exceptions : bool
110
111
) -> Future [tuple [_T1 | BaseException , _T2 | BaseException ]]: ...
111
112
@overload
112
- def gather (
113
+ def gather ( # type: ignore[misc]
113
114
__coro_or_future1 : _FutureLike [_T1 ],
114
115
__coro_or_future2 : _FutureLike [_T2 ],
115
116
__coro_or_future3 : _FutureLike [_T3 ],
116
117
* ,
117
118
return_exceptions : bool ,
118
119
) -> Future [tuple [_T1 | BaseException , _T2 | BaseException , _T3 | BaseException ]]: ...
119
120
@overload
120
- def gather (
121
+ def gather ( # type: ignore[misc]
121
122
__coro_or_future1 : _FutureLike [_T1 ],
122
123
__coro_or_future2 : _FutureLike [_T2 ],
123
124
__coro_or_future3 : _FutureLike [_T3 ],
@@ -126,7 +127,7 @@ if sys.version_info >= (3, 10):
126
127
return_exceptions : bool ,
127
128
) -> Future [tuple [_T1 | BaseException , _T2 | BaseException , _T3 | BaseException , _T4 | BaseException ]]: ...
128
129
@overload
129
- def gather (
130
+ def gather ( # type: ignore[misc]
130
131
__coro_or_future1 : _FutureLike [_T1 ],
131
132
__coro_or_future2 : _FutureLike [_T2 ],
132
133
__coro_or_future3 : _FutureLike [_T3 ],
@@ -138,34 +139,23 @@ if sys.version_info >= (3, 10):
138
139
tuple [_T1 | BaseException , _T2 | BaseException , _T3 | BaseException , _T4 | BaseException , _T5 | BaseException ]
139
140
]: ...
140
141
@overload
141
- def gather (
142
- __coro_or_future1 : _FutureLike [Any ],
143
- __coro_or_future2 : _FutureLike [Any ],
144
- __coro_or_future3 : _FutureLike [Any ],
145
- __coro_or_future4 : _FutureLike [Any ],
146
- __coro_or_future5 : _FutureLike [Any ],
147
- __coro_or_future6 : _FutureLike [Any ],
148
- * coros_or_futures : _FutureLike [Any ],
149
- return_exceptions : bool = ...,
150
- ) -> Future [list [Any ]]: ...
142
+ def gather (* coros_or_futures : _FutureLike [Any ], return_exceptions : bool = ...) -> Future [list [Any ]]: ... # type: ignore[misc]
151
143
152
144
else :
153
145
@overload
154
- def gather (* , loop : AbstractEventLoop | None = ..., return_exceptions : bool = ...) -> Future [tuple [()]]: ...
155
- @overload
156
- def gather (
146
+ def gather ( # type: ignore[misc]
157
147
__coro_or_future1 : _FutureLike [_T1 ], * , loop : AbstractEventLoop | None = ..., return_exceptions : Literal [False ] = ...
158
148
) -> Future [tuple [_T1 ]]: ...
159
149
@overload
160
- def gather (
150
+ def gather ( # type: ignore[misc]
161
151
__coro_or_future1 : _FutureLike [_T1 ],
162
152
__coro_or_future2 : _FutureLike [_T2 ],
163
153
* ,
164
154
loop : AbstractEventLoop | None = ...,
165
155
return_exceptions : Literal [False ] = ...,
166
156
) -> Future [tuple [_T1 , _T2 ]]: ...
167
157
@overload
168
- def gather (
158
+ def gather ( # type: ignore[misc]
169
159
__coro_or_future1 : _FutureLike [_T1 ],
170
160
__coro_or_future2 : _FutureLike [_T2 ],
171
161
__coro_or_future3 : _FutureLike [_T3 ],
@@ -174,7 +164,7 @@ else:
174
164
return_exceptions : Literal [False ] = ...,
175
165
) -> Future [tuple [_T1 , _T2 , _T3 ]]: ...
176
166
@overload
177
- def gather (
167
+ def gather ( # type: ignore[misc]
178
168
__coro_or_future1 : _FutureLike [_T1 ],
179
169
__coro_or_future2 : _FutureLike [_T2 ],
180
170
__coro_or_future3 : _FutureLike [_T3 ],
@@ -184,7 +174,7 @@ else:
184
174
return_exceptions : Literal [False ] = ...,
185
175
) -> Future [tuple [_T1 , _T2 , _T3 , _T4 ]]: ...
186
176
@overload
187
- def gather (
177
+ def gather ( # type: ignore[misc]
188
178
__coro_or_future1 : _FutureLike [_T1 ],
189
179
__coro_or_future2 : _FutureLike [_T2 ],
190
180
__coro_or_future3 : _FutureLike [_T3 ],
@@ -195,19 +185,19 @@ else:
195
185
return_exceptions : Literal [False ] = ...,
196
186
) -> Future [tuple [_T1 , _T2 , _T3 , _T4 , _T5 ]]: ...
197
187
@overload
198
- def gather (
188
+ def gather ( # type: ignore[misc]
199
189
__coro_or_future1 : _FutureLike [_T1 ], * , loop : AbstractEventLoop | None = ..., return_exceptions : bool
200
190
) -> Future [tuple [_T1 | BaseException ]]: ...
201
191
@overload
202
- def gather (
192
+ def gather ( # type: ignore[misc]
203
193
__coro_or_future1 : _FutureLike [_T1 ],
204
194
__coro_or_future2 : _FutureLike [_T2 ],
205
195
* ,
206
196
loop : AbstractEventLoop | None = ...,
207
197
return_exceptions : bool ,
208
198
) -> Future [tuple [_T1 | BaseException , _T2 | BaseException ]]: ...
209
199
@overload
210
- def gather (
200
+ def gather ( # type: ignore[misc]
211
201
__coro_or_future1 : _FutureLike [_T1 ],
212
202
__coro_or_future2 : _FutureLike [_T2 ],
213
203
__coro_or_future3 : _FutureLike [_T3 ],
@@ -216,7 +206,7 @@ else:
216
206
return_exceptions : bool ,
217
207
) -> Future [tuple [_T1 | BaseException , _T2 | BaseException , _T3 | BaseException ]]: ...
218
208
@overload
219
- def gather (
209
+ def gather ( # type: ignore[misc]
220
210
__coro_or_future1 : _FutureLike [_T1 ],
221
211
__coro_or_future2 : _FutureLike [_T2 ],
222
212
__coro_or_future3 : _FutureLike [_T3 ],
@@ -226,7 +216,7 @@ else:
226
216
return_exceptions : bool ,
227
217
) -> Future [tuple [_T1 | BaseException , _T2 | BaseException , _T3 | BaseException , _T4 | BaseException ]]: ...
228
218
@overload
229
- def gather (
219
+ def gather ( # type: ignore[misc]
230
220
__coro_or_future1 : _FutureLike [_T1 ],
231
221
__coro_or_future2 : _FutureLike [_T2 ],
232
222
__coro_or_future3 : _FutureLike [_T3 ],
@@ -239,16 +229,8 @@ else:
239
229
tuple [_T1 | BaseException , _T2 | BaseException , _T3 | BaseException , _T4 | BaseException , _T5 | BaseException ]
240
230
]: ...
241
231
@overload
242
- def gather (
243
- __coro_or_future1 : _FutureLike [Any ],
244
- __coro_or_future2 : _FutureLike [Any ],
245
- __coro_or_future3 : _FutureLike [Any ],
246
- __coro_or_future4 : _FutureLike [Any ],
247
- __coro_or_future5 : _FutureLike [Any ],
248
- __coro_or_future6 : _FutureLike [Any ],
249
- * coros_or_futures : _FutureLike [Any ],
250
- loop : AbstractEventLoop | None = ...,
251
- return_exceptions : bool = ...,
232
+ def gather ( # type: ignore[misc]
233
+ * coros_or_futures : _FutureLike [Any ], loop : AbstractEventLoop | None = ..., return_exceptions : bool = ...
252
234
) -> Future [list [Any ]]: ...
253
235
254
236
def run_coroutine_threadsafe (coro : _FutureLike [_T ], loop : AbstractEventLoop ) -> concurrent .futures .Future [_T ]: ...
0 commit comments