Skip to content

Commit 1b267b2

Browse files
authored
stdlib/unittest/mock.pyi: Improve _Call types (#13845)
This fixes a number of issues related to `_Call` in `stdlib/unittest/mock.pyi`: - `_Call.__new__()`, `_Call.__init__()`: The `parent` argument should be another `_Call` or `None`. - `_Call.name` doesn't exist. - `_Call.parent` doesn't exist. - `_Call.from_kall` doesn't exist. - [`NonCallableMock.call_args`][0] should be a `_Call` or `None`. [0]: https://docs.python.org/3/library/unittest.mock.html#unittest.mock.Mock.call_args
1 parent 6f7c797 commit 1b267b2

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

Diff for: stdlib/unittest/mock.pyi

+4-6
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import sys
2+
from _typeshed import MaybeNone
23
from collections.abc import Awaitable, Callable, Coroutine, Iterable, Mapping, Sequence
34
from contextlib import _GeneratorContextManager
45
from types import TracebackType
@@ -69,16 +70,13 @@ _CallValue: TypeAlias = str | tuple[Any, ...] | Mapping[str, Any] | _ArgsKwargs
6970

7071
class _Call(tuple[Any, ...]):
7172
def __new__(
72-
cls, value: _CallValue = (), name: str | None = "", parent: Any | None = None, two: bool = False, from_kall: bool = True
73+
cls, value: _CallValue = (), name: str | None = "", parent: _Call | None = None, two: bool = False, from_kall: bool = True
7374
) -> Self: ...
74-
name: Any
75-
parent: Any
76-
from_kall: Any
7775
def __init__(
7876
self,
7977
value: _CallValue = (),
8078
name: str | None = None,
81-
parent: Any | None = None,
79+
parent: _Call | None = None,
8280
two: bool = False,
8381
from_kall: bool = True,
8482
) -> None: ...
@@ -162,7 +160,7 @@ class NonCallableMock(Base, Any):
162160
side_effect: Any
163161
called: bool
164162
call_count: int
165-
call_args: Any
163+
call_args: _Call | MaybeNone
166164
call_args_list: _CallList
167165
mock_calls: _CallList
168166
def _format_mock_call_signature(self, args: Any, kwargs: Any) -> str: ...

0 commit comments

Comments
 (0)