@@ -204,112 +204,112 @@ class _patcher:
204
204
TEST_PREFIX : str
205
205
dict : Type [_patch_dict ]
206
206
if sys .version_info >= (3 , 8 ):
207
+ # This overload also covers the case, where new==DEFAULT. In this case, the return type is _patch[Any].
208
+ # Ideally we'd be able to add an overload for it so that the return type is _patch[MagicMock],
209
+ # but that's impossible with the current type system.
207
210
@overload
208
211
def __call__ ( # type: ignore
209
212
self ,
210
213
target : Any ,
211
- * ,
214
+ new : _T ,
212
215
spec : Optional [Any ] = ...,
213
216
create : bool = ...,
214
217
spec_set : Optional [Any ] = ...,
215
218
autospec : Optional [Any ] = ...,
216
219
new_callable : Optional [Any ] = ...,
217
220
** kwargs : Any ,
218
- ) -> _patch [Union [MagicMock , AsyncMock ]]: ...
219
- # This overload also covers the case, where new==DEFAULT. In this case, the return type is _patch[Any].
220
- # Ideally we'd be able to add an overload for it so that the return type is _patch[MagicMock],
221
- # but that's impossible with the current type system.
221
+ ) -> _patch [_T ]: ...
222
222
@overload
223
- def __call__ (
223
+ def __call__ ( # type: ignore
224
224
self ,
225
225
target : Any ,
226
- new : _T ,
226
+ * ,
227
227
spec : Optional [Any ] = ...,
228
228
create : bool = ...,
229
229
spec_set : Optional [Any ] = ...,
230
230
autospec : Optional [Any ] = ...,
231
231
new_callable : Optional [Any ] = ...,
232
232
** kwargs : Any ,
233
- ) -> _patch [_T ]: ...
233
+ ) -> _patch [Union [ MagicMock , AsyncMock ] ]: ...
234
234
else :
235
235
@overload
236
236
def __call__ ( # type: ignore
237
237
self ,
238
238
target : Any ,
239
- * ,
239
+ new : _T ,
240
240
spec : Optional [Any ] = ...,
241
241
create : bool = ...,
242
242
spec_set : Optional [Any ] = ...,
243
243
autospec : Optional [Any ] = ...,
244
244
new_callable : Optional [Any ] = ...,
245
245
** kwargs : Any ,
246
- ) -> _patch [MagicMock ]: ...
246
+ ) -> _patch [_T ]: ...
247
247
@overload
248
- def __call__ (
248
+ def __call__ ( # type: ignore
249
249
self ,
250
250
target : Any ,
251
- new : _T ,
251
+ * ,
252
252
spec : Optional [Any ] = ...,
253
253
create : bool = ...,
254
254
spec_set : Optional [Any ] = ...,
255
255
autospec : Optional [Any ] = ...,
256
256
new_callable : Optional [Any ] = ...,
257
257
** kwargs : Any ,
258
- ) -> _patch [_T ]: ...
258
+ ) -> _patch [MagicMock ]: ...
259
259
if sys .version_info >= (3 , 8 ):
260
260
@overload
261
261
def object ( # type: ignore
262
262
self ,
263
263
target : Any ,
264
264
attribute : str ,
265
- * ,
265
+ new : _T ,
266
266
spec : Optional [Any ] = ...,
267
267
create : bool = ...,
268
268
spec_set : Optional [Any ] = ...,
269
269
autospec : Optional [Any ] = ...,
270
270
new_callable : Optional [Any ] = ...,
271
271
** kwargs : Any ,
272
- ) -> _patch [Union [ MagicMock , AsyncMock ] ]: ...
272
+ ) -> _patch [_T ]: ...
273
273
@overload
274
- def object (
274
+ def object ( # type: ignore
275
275
self ,
276
276
target : Any ,
277
277
attribute : str ,
278
- new : _T = ... ,
278
+ * ,
279
279
spec : Optional [Any ] = ...,
280
280
create : bool = ...,
281
281
spec_set : Optional [Any ] = ...,
282
282
autospec : Optional [Any ] = ...,
283
283
new_callable : Optional [Any ] = ...,
284
284
** kwargs : Any ,
285
- ) -> _patch [_T ]: ...
285
+ ) -> _patch [Union [ MagicMock , AsyncMock ] ]: ...
286
286
else :
287
287
@overload
288
288
def object ( # type: ignore
289
289
self ,
290
290
target : Any ,
291
291
attribute : str ,
292
- * ,
292
+ new : _T ,
293
293
spec : Optional [Any ] = ...,
294
294
create : bool = ...,
295
295
spec_set : Optional [Any ] = ...,
296
296
autospec : Optional [Any ] = ...,
297
297
new_callable : Optional [Any ] = ...,
298
298
** kwargs : Any ,
299
- ) -> _patch [MagicMock ]: ...
299
+ ) -> _patch [_T ]: ...
300
300
@overload
301
- def object (
301
+ def object ( # type: ignore
302
302
self ,
303
303
target : Any ,
304
304
attribute : str ,
305
- new : _T = ... ,
305
+ * ,
306
306
spec : Optional [Any ] = ...,
307
307
create : bool = ...,
308
308
spec_set : Optional [Any ] = ...,
309
309
autospec : Optional [Any ] = ...,
310
310
new_callable : Optional [Any ] = ...,
311
311
** kwargs : Any ,
312
- ) -> _patch [_T ]: ...
312
+ ) -> _patch [MagicMock ]: ...
313
313
def multiple (
314
314
self ,
315
315
target : Any ,
0 commit comments