Skip to content

Commit

Permalink
Add a more precise signature for AsyncMock.reset_mock() (#10481)
Browse files Browse the repository at this point in the history
  • Loading branch information
sobolevn authored Jul 19, 2023
1 parent 9e7477d commit 032f919
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
6 changes: 5 additions & 1 deletion stdlib/unittest/mock.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,11 @@ if sys.version_info >= (3, 8):
class AsyncMagicMixin(MagicMixin):
def __init__(self, *args: Any, **kw: Any) -> None: ...

class AsyncMock(AsyncMockMixin, AsyncMagicMixin, Mock): ...
class AsyncMock(AsyncMockMixin, AsyncMagicMixin, Mock):
# Improving the `reset_mock` signature.
# It is defined on `AsyncMockMixin` with `*args, **kwargs`, which is not ideal.
# But, `NonCallableMock` super-class has the better version.
def reset_mock(self, visited: Any = None, *, return_value: bool = False, side_effect: bool = False) -> None: ...

class MagicProxy:
name: str
Expand Down
7 changes: 6 additions & 1 deletion stubs/mock/mock/mock.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,12 @@ class AsyncMockMixin(Base):
__annotations__: dict[str, Any] | None # type: ignore[assignment]

class AsyncMagicMixin(MagicMixin): ...
class AsyncMock(AsyncMockMixin, AsyncMagicMixin, Mock): ...

class AsyncMock(AsyncMockMixin, AsyncMagicMixin, Mock):
# Improving the `reset_mock` signature.
# It is defined on `AsyncMockMixin` with `*args, **kwargs`, which is not ideal.
# But, `NonCallableMock` super-class has the better version.
def reset_mock(self, visited: Any = None, *, return_value: bool = False, side_effect: bool = False) -> None: ...

class MagicProxy(Base):
name: str
Expand Down

0 comments on commit 032f919

Please sign in to comment.