Skip to content

Commit 2157c4a

Browse files
authored
Fix patch() used as decorator (#4592)
Closes: #4591
1 parent 8427e09 commit 2157c4a

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

stdlib/3/unittest/mock.pyi

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ from typing import Any, Callable, Generic, List, Mapping, Optional, Sequence, Te
44
_F = TypeVar("_F", bound=Callable[..., Any])
55
_T = TypeVar("_T")
66
_TT = TypeVar("_TT", bound=Type[Any])
7+
_R = TypeVar("_R")
78

89
__all__ = [
910
"Mock",
@@ -193,7 +194,7 @@ class _patch(Generic[_T]):
193194
kwargs: Mapping[str, Any],
194195
) -> None: ...
195196
def copy(self) -> _patch[_T]: ...
196-
def __call__(self, func: _F) -> _F: ...
197+
def __call__(self, func: Callable[..., _R]) -> Callable[..., _R]: ...
197198
def decorate_class(self, klass: _TT) -> _TT: ...
198199
def decorate_callable(self, func: _F) -> _F: ...
199200
def get_original(self) -> Tuple[Any, bool]: ...

third_party/2and3/mock.pyi

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ from typing import Any, Callable, Generic, List, Mapping, Optional, Sequence, Te
44
_F = TypeVar("_F", bound=Callable[..., Any])
55
_T = TypeVar("_T")
66
_TT = TypeVar("_TT", bound=Type[Any])
7+
_R = TypeVar("_R")
78

89
__all__ = [
910
"Mock",
@@ -193,7 +194,7 @@ class _patch(Generic[_T]):
193194
kwargs: Mapping[str, Any],
194195
) -> None: ...
195196
def copy(self) -> _patch[_T]: ...
196-
def __call__(self, func: _F) -> _F: ...
197+
def __call__(self, func: Callable[..., _R]) -> Callable[..., _R]: ...
197198
def decorate_class(self, klass: _TT) -> _TT: ...
198199
def decorate_callable(self, func: _F) -> _F: ...
199200
def get_original(self) -> Tuple[Any, bool]: ...

0 commit comments

Comments
 (0)