@@ -164,63 +164,35 @@ class _patch(Generic[_T]):
164
164
autospec : Any
165
165
kwargs : Mapping [str , Any ]
166
166
additional_patchers : Any
167
- if sys .version_info >= (3 , 8 ):
168
- @overload
169
- def __init__ (
170
- self : _patch [MagicMock | AsyncMock ],
171
- getter : Callable [[], Any ],
172
- attribute : str ,
173
- * ,
174
- spec : Any | None ,
175
- create : bool ,
176
- spec_set : Any | None ,
177
- autospec : Any | None ,
178
- new_callable : Any | None ,
179
- kwargs : Mapping [str , Any ],
180
- ) -> None : ...
181
- # This overload also covers the case, where new==DEFAULT. In this case, self is _patch[Any].
182
- # Ideally we'd be able to add an overload for it so that self is _patch[MagicMock],
183
- # but that's impossible with the current type system.
184
- @overload
185
- def __init__ (
186
- self : _patch [_T ],
187
- getter : Callable [[], Any ],
188
- attribute : str ,
189
- new : _T ,
190
- spec : Any | None ,
191
- create : bool ,
192
- spec_set : Any | None ,
193
- autospec : Any | None ,
194
- new_callable : Any | None ,
195
- kwargs : Mapping [str , Any ],
196
- ) -> None : ...
197
- else :
198
- @overload
199
- def __init__ (
200
- self : _patch [MagicMock ],
201
- getter : Callable [[], Any ],
202
- attribute : str ,
203
- * ,
204
- spec : Any | None ,
205
- create : bool ,
206
- spec_set : Any | None ,
207
- autospec : Any | None ,
208
- new_callable : Any | None ,
209
- kwargs : Mapping [str , Any ],
210
- ) -> None : ...
211
- @overload
212
- def __init__ (
213
- self : _patch [_T ],
214
- getter : Callable [[], Any ],
215
- attribute : str ,
216
- new : _T ,
217
- spec : Any | None ,
218
- create : bool ,
219
- spec_set : Any | None ,
220
- autospec : Any | None ,
221
- new_callable : Any | None ,
222
- kwargs : Mapping [str , Any ],
223
- ) -> None : ...
167
+ @overload
168
+ def __init__ (
169
+ self : _patch [MagicMock | AsyncMock ],
170
+ getter : Callable [[], Any ],
171
+ attribute : str ,
172
+ * ,
173
+ spec : Any | None ,
174
+ create : bool ,
175
+ spec_set : Any | None ,
176
+ autospec : Any | None ,
177
+ new_callable : Any | None ,
178
+ kwargs : Mapping [str , Any ],
179
+ ) -> None : ...
180
+ # This overload also covers the case, where new==DEFAULT. In this case, self is _patch[Any].
181
+ # Ideally we'd be able to add an overload for it so that self is _patch[MagicMock],
182
+ # but that's impossible with the current type system.
183
+ @overload
184
+ def __init__ (
185
+ self : _patch [_T ],
186
+ getter : Callable [[], Any ],
187
+ attribute : str ,
188
+ new : _T ,
189
+ spec : Any | None ,
190
+ create : bool ,
191
+ spec_set : Any | None ,
192
+ autospec : Any | None ,
193
+ new_callable : Any | None ,
194
+ kwargs : Mapping [str , Any ],
195
+ ) -> None : ...
224
196
def copy (self ) -> _patch [_T ]: ...
225
197
def __call__ (self , func : Callable [..., _R ]) -> Callable [..., _R ]: ...
226
198
def decorate_class (self , klass : _TT ) -> _TT : ...
@@ -249,113 +221,59 @@ class _patch_dict:
249
221
class _patcher :
250
222
TEST_PREFIX : str
251
223
dict : Type [_patch_dict ]
252
- if sys .version_info >= (3 , 8 ):
253
- @overload
254
- def __call__ ( # type: ignore
255
- self ,
256
- target : Any ,
257
- * ,
258
- spec : Any | None = ...,
259
- create : bool = ...,
260
- spec_set : Any | None = ...,
261
- autospec : Any | None = ...,
262
- new_callable : Any | None = ...,
263
- ** kwargs : Any ,
264
- ) -> _patch [MagicMock | AsyncMock ]: ...
265
- # This overload also covers the case, where new==DEFAULT. In this case, the return type is _patch[Any].
266
- # Ideally we'd be able to add an overload for it so that the return type is _patch[MagicMock],
267
- # but that's impossible with the current type system.
268
- @overload
269
- def __call__ (
270
- self ,
271
- target : Any ,
272
- new : _T ,
273
- spec : Any | None = ...,
274
- create : bool = ...,
275
- spec_set : Any | None = ...,
276
- autospec : Any | None = ...,
277
- new_callable : Any | None = ...,
278
- ** kwargs : Any ,
279
- ) -> _patch [_T ]: ...
280
- else :
281
- @overload
282
- def __call__ ( # type: ignore
283
- self ,
284
- target : Any ,
285
- * ,
286
- spec : Any | None = ...,
287
- create : bool = ...,
288
- spec_set : Any | None = ...,
289
- autospec : Any | None = ...,
290
- new_callable : Any | None = ...,
291
- ** kwargs : Any ,
292
- ) -> _patch [MagicMock ]: ...
293
- @overload
294
- def __call__ (
295
- self ,
296
- target : Any ,
297
- new : _T ,
298
- spec : Any | None = ...,
299
- create : bool = ...,
300
- spec_set : Any | None = ...,
301
- autospec : Any | None = ...,
302
- new_callable : Any | None = ...,
303
- ** kwargs : Any ,
304
- ) -> _patch [_T ]: ...
305
- if sys .version_info >= (3 , 8 ):
306
- @overload
307
- def object ( # type: ignore
308
- self ,
309
- target : Any ,
310
- attribute : Text ,
311
- * ,
312
- spec : Any | None = ...,
313
- create : bool = ...,
314
- spec_set : Any | None = ...,
315
- autospec : Any | None = ...,
316
- new_callable : Any | None = ...,
317
- ** kwargs : Any ,
318
- ) -> _patch [MagicMock | AsyncMock ]: ...
319
- @overload
320
- def object (
321
- self ,
322
- target : Any ,
323
- attribute : Text ,
324
- new : _T = ...,
325
- spec : Any | None = ...,
326
- create : bool = ...,
327
- spec_set : Any | None = ...,
328
- autospec : Any | None = ...,
329
- new_callable : Any | None = ...,
330
- ** kwargs : Any ,
331
- ) -> _patch [_T ]: ...
332
- else :
333
- @overload
334
- def object ( # type: ignore
335
- self ,
336
- target : Any ,
337
- attribute : Text ,
338
- * ,
339
- spec : Any | None = ...,
340
- create : bool = ...,
341
- spec_set : Any | None = ...,
342
- autospec : Any | None = ...,
343
- new_callable : Any | None = ...,
344
- ** kwargs : Any ,
345
- ) -> _patch [MagicMock ]: ...
346
- @overload
347
- def object (
348
- self ,
349
- target : Any ,
350
- attribute : Text ,
351
- new : _T = ...,
352
- spec : Any | None = ...,
353
- create : bool = ...,
354
- spec_set : Any | None = ...,
355
- autospec : Any | None = ...,
356
- new_callable : Any | None = ...,
357
- ** kwargs : Any ,
358
- ) -> _patch [_T ]: ...
224
+ @overload
225
+ def __call__ ( # type: ignore
226
+ self ,
227
+ target : Any ,
228
+ * ,
229
+ spec : Any | None = ...,
230
+ create : bool = ...,
231
+ spec_set : Any | None = ...,
232
+ autospec : Any | None = ...,
233
+ new_callable : Any | None = ...,
234
+ ** kwargs : Any ,
235
+ ) -> _patch [MagicMock | AsyncMock ]: ...
236
+ # This overload also covers the case, where new==DEFAULT. In this case, the return type is _patch[Any].
237
+ # Ideally we'd be able to add an overload for it so that the return type is _patch[MagicMock],
238
+ # but that's impossible with the current type system.
239
+ @overload
240
+ def __call__ (
241
+ self ,
242
+ target : Any ,
243
+ new : _T ,
244
+ spec : Any | None = ...,
245
+ create : bool = ...,
246
+ spec_set : Any | None = ...,
247
+ autospec : Any | None = ...,
248
+ new_callable : Any | None = ...,
249
+ ** kwargs : Any ,
250
+ ) -> _patch [_T ]: ...
251
+ @overload
252
+ def object ( # type: ignore
253
+ self ,
254
+ target : Any ,
255
+ attribute : Text ,
256
+ * ,
257
+ spec : Any | None = ...,
258
+ create : bool = ...,
259
+ spec_set : Any | None = ...,
260
+ autospec : Any | None = ...,
261
+ new_callable : Any | None = ...,
262
+ ** kwargs : Any ,
263
+ ) -> _patch [MagicMock | AsyncMock ]: ...
264
+ @overload
265
+ def object (
266
+ self ,
267
+ target : Any ,
268
+ attribute : Text ,
269
+ new : _T = ...,
270
+ spec : Any | None = ...,
271
+ create : bool = ...,
272
+ spec_set : Any | None = ...,
273
+ autospec : Any | None = ...,
274
+ new_callable : Any | None = ...,
275
+ ** kwargs : Any ,
276
+ ) -> _patch [_T ]: ...
359
277
def multiple (
360
278
self ,
361
279
target : Any ,
@@ -379,24 +297,25 @@ class NonCallableMagicMock(MagicMixin, NonCallableMock):
379
297
class MagicMock (MagicMixin , Mock ):
380
298
def mock_add_spec (self , spec : Any , spec_set : bool = ...) -> None : ...
381
299
382
- if sys .version_info >= (3 , 8 ):
383
- class AsyncMockMixin (Base ):
384
- def __init__ (self , * args : Any , ** kwargs : Any ) -> None : ...
385
- async def _execute_mock_call (self , * args : Any , ** kwargs : Any ) -> Any : ...
386
- def assert_awaited (self ) -> None : ...
387
- def assert_awaited_once (self ) -> None : ...
388
- def assert_awaited_with (self , * args : Any , ** kwargs : Any ) -> None : ...
389
- def assert_awaited_once_with (self , * args : Any , ** kwargs : Any ) -> None : ...
390
- def assert_any_await (self , * args : Any , ** kwargs : Any ) -> None : ...
391
- def assert_has_awaits (self , calls : _CallList , any_order : bool = ...) -> None : ...
392
- def assert_not_awaited (self ) -> None : ...
393
- def reset_mock (self , * args : Any , ** kwargs : Any ) -> None : ...
394
- await_count : int
395
- await_args : _Call | None
396
- await_args_list : _CallList
397
- class AsyncMagicMixin (MagicMixin ):
398
- def __init__ (self , * args : Any , ** kw : Any ) -> None : ...
399
- class AsyncMock (AsyncMockMixin , AsyncMagicMixin , Mock ): ...
300
+ class AsyncMockMixin (Base ):
301
+ def __init__ (self , * args : Any , ** kwargs : Any ) -> None : ...
302
+ async def _execute_mock_call (self , * args : Any , ** kwargs : Any ) -> Any : ...
303
+ def assert_awaited (self ) -> None : ...
304
+ def assert_awaited_once (self ) -> None : ...
305
+ def assert_awaited_with (self , * args : Any , ** kwargs : Any ) -> None : ...
306
+ def assert_awaited_once_with (self , * args : Any , ** kwargs : Any ) -> None : ...
307
+ def assert_any_await (self , * args : Any , ** kwargs : Any ) -> None : ...
308
+ def assert_has_awaits (self , calls : _CallList , any_order : bool = ...) -> None : ...
309
+ def assert_not_awaited (self ) -> None : ...
310
+ def reset_mock (self , * args : Any , ** kwargs : Any ) -> None : ...
311
+ await_count : int
312
+ await_args : _Call | None
313
+ await_args_list : _CallList
314
+
315
+ class AsyncMagicMixin (MagicMixin ):
316
+ def __init__ (self , * args : Any , ** kw : Any ) -> None : ...
317
+
318
+ class AsyncMock (AsyncMockMixin , AsyncMagicMixin , Mock ): ...
400
319
401
320
class MagicProxy :
402
321
name : Any
0 commit comments