From 452c1e1d78a5eeead2d24ca0b8693891653e58c5 Mon Sep 17 00:00:00 2001 From: Roy Williams Date: Thu, 6 Apr 2017 18:47:28 -0700 Subject: [PATCH] Fix patch.object to return a _patch context manager. (#1142) * Fix patch.object to return a _patch context manager. This should fix https://github.com/python/typeshed/issues/914 * Prefer None over ... to be consistent with the rest of the file. --- stdlib/3/unittest/mock.pyi | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/stdlib/3/unittest/mock.pyi b/stdlib/3/unittest/mock.pyi index 5a3f6b00f..84fe40e45 100644 --- a/stdlib/3/unittest/mock.pyi +++ b/stdlib/3/unittest/mock.pyi @@ -92,7 +92,11 @@ if sys.version_info >= (3, 3): def start(self) -> Any: ... def stop(self) -> Any: ... - def patch(target: Any, new: Any =..., spec: Any = None, create: Any = False, spec_set: Any = None, autospec: Any = None, new_callable: Any = None, **kwargs: Any) -> Any: ... + class _patcher: + def __call__(self, target: Any, new: Any = None, spec: Any = None, create: Any = False, spec_set: Any = None, autospec: Any = None, new_callable: Any = None, **kwargs: Any) -> Any: ... + def object(self, target: Any, attribute: str, new: Any = None, spec: Any = None, create: Any = False, spec_set: Any = None, autospec: Any = None, new_callable: Any = None, **kwargs: Any) -> _patch: ... + + patch = ... # type: _patcher class _patch_dict: in_dict = ... # type: Any