massive update, probably broken
[dotfiles/.git] / .config / coc / extensions / node_modules / coc-pyright / node_modules / pyright / dist / typeshed-fallback / stubs / mock / mock / mock.pyi
1 from collections.abc import Callable, Mapping, Sequence
2 from typing import Any, Generic, List, Tuple, Type, TypeVar, overload
3
4 _F = TypeVar("_F", bound=Callable[..., Any])
5 _T = TypeVar("_T")
6 _TT = TypeVar("_TT", bound=Type[Any])
7 _R = TypeVar("_R")
8
9 __all__ = [
10     "Mock",
11     "MagicMock",
12     "patch",
13     "sentinel",
14     "DEFAULT",
15     "ANY",
16     "call",
17     "create_autospec",
18     "AsyncMock",
19     "FILTER_DIR",
20     "NonCallableMock",
21     "NonCallableMagicMock",
22     "mock_open",
23     "PropertyMock",
24     "seal",
25 ]
26 __version__: str
27
28 FILTER_DIR: Any
29
30 class _slotted: ...
31
32 class _SentinelObject:
33     name: Any
34     def __init__(self, name: Any) -> None: ...
35
36 class _Sentinel:
37     def __init__(self) -> None: ...
38     def __getattr__(self, name: str) -> Any: ...
39
40 sentinel: Any
41 DEFAULT: Any
42
43 class _Call(Tuple[Any, ...]):
44     def __new__(
45         cls, value: Any = ..., name: Any | None = ..., parent: Any | None = ..., two: bool = ..., from_kall: bool = ...
46     ) -> Any: ...
47     name: Any
48     parent: Any
49     from_kall: Any
50     def __init__(
51         self, value: Any = ..., name: Any | None = ..., parent: Any | None = ..., two: bool = ..., from_kall: bool = ...
52     ) -> None: ...
53     def __eq__(self, other: Any) -> bool: ...
54     __ne__: Any
55     def __call__(self, *args: Any, **kwargs: Any) -> _Call: ...
56     def __getattr__(self, attr: Any) -> Any: ...
57     def count(self, *args: Any, **kwargs: Any) -> Any: ...
58     def index(self, *args: Any, **kwargs: Any) -> Any: ...
59     def call_list(self) -> Any: ...
60
61 call: _Call
62
63 class _CallList(List[_Call]):
64     def __contains__(self, value: Any) -> bool: ...
65
66 class _MockIter:
67     obj: Any
68     def __init__(self, obj: Any) -> None: ...
69     def __iter__(self) -> Any: ...
70     def __next__(self) -> Any: ...
71
72 class Base:
73     def __init__(self, *args: Any, **kwargs: Any) -> None: ...
74
75 class NonCallableMock(Base, Any):  # type: ignore
76     def __new__(__cls, *args: Any, **kw: Any) -> NonCallableMock: ...
77     def __init__(
78         self,
79         spec: list[str] | object | Type[object] | None = ...,
80         wraps: Any | None = ...,
81         name: str | None = ...,
82         spec_set: list[str] | object | Type[object] | None = ...,
83         parent: NonCallableMock | None = ...,
84         _spec_state: Any | None = ...,
85         _new_name: str = ...,
86         _new_parent: NonCallableMock | None = ...,
87         _spec_as_instance: bool = ...,
88         _eat_self: bool | None = ...,
89         unsafe: bool = ...,
90         **kwargs: Any,
91     ) -> None: ...
92     def __getattr__(self, name: str) -> Any: ...
93     def _calls_repr(self, prefix: str = ...) -> str: ...
94     def assert_called_with(_mock_self, *args: Any, **kwargs: Any) -> None: ...
95     def assert_not_called(_mock_self) -> None: ...
96     def assert_called_once_with(_mock_self, *args: Any, **kwargs: Any) -> None: ...
97     def _format_mock_failure_message(self, args: Any, kwargs: Any, action: str = ...) -> str: ...
98     def assert_called(_mock_self) -> None: ...
99     def assert_called_once(_mock_self) -> None: ...
100     def reset_mock(self, visited: Any = ..., *, return_value: bool = ..., side_effect: bool = ...) -> None: ...
101     def _extract_mock_name(self) -> str: ...
102     def assert_any_call(self, *args: Any, **kwargs: Any) -> None: ...
103     def assert_has_calls(self, calls: Sequence[_Call], any_order: bool = ...) -> None: ...
104     def mock_add_spec(self, spec: Any, spec_set: bool = ...) -> None: ...
105     def _mock_add_spec(self, spec: Any, spec_set: bool, _spec_as_instance: bool = ..., _eat_self: bool = ...) -> None: ...
106     def attach_mock(self, mock: NonCallableMock, attribute: str) -> None: ...
107     def configure_mock(self, **kwargs: Any) -> None: ...
108     return_value: Any
109     side_effect: Any
110     called: bool
111     call_count: int
112     call_args: Any
113     call_args_list: _CallList
114     mock_calls: _CallList
115     def _format_mock_call_signature(self, args: Any, kwargs: Any) -> str: ...
116     def _call_matcher(self, _call: Tuple[_Call, ...]) -> _Call: ...
117     def _get_child_mock(self, **kw: Any) -> NonCallableMock: ...
118
119 class CallableMixin(Base):
120     side_effect: Any
121     def __init__(
122         self,
123         spec: Any | None = ...,
124         side_effect: Any | None = ...,
125         return_value: Any = ...,
126         wraps: Any | None = ...,
127         name: Any | None = ...,
128         spec_set: Any | None = ...,
129         parent: Any | None = ...,
130         _spec_state: Any | None = ...,
131         _new_name: Any = ...,
132         _new_parent: Any | None = ...,
133         **kwargs: Any,
134     ) -> None: ...
135     def __call__(_mock_self, *args: Any, **kwargs: Any) -> Any: ...
136
137 class Mock(CallableMixin, NonCallableMock): ...
138
139 class _patch(Generic[_T]):
140     attribute_name: Any
141     getter: Callable[[], Any]
142     attribute: str
143     new: _T
144     new_callable: Any
145     spec: Any
146     create: bool
147     has_local: Any
148     spec_set: Any
149     autospec: Any
150     kwargs: Mapping[str, Any]
151     additional_patchers: Any
152     @overload
153     def __init__(
154         self: _patch[MagicMock | AsyncMock],
155         getter: Callable[[], Any],
156         attribute: str,
157         *,
158         spec: Any | None,
159         create: bool,
160         spec_set: Any | None,
161         autospec: Any | None,
162         new_callable: Any | None,
163         kwargs: Mapping[str, Any],
164     ) -> None: ...
165     # This overload also covers the case, where new==DEFAULT. In this case, self is _patch[Any].
166     # Ideally we'd be able to add an overload for it so that self is _patch[MagicMock],
167     # but that's impossible with the current type system.
168     @overload
169     def __init__(
170         self: _patch[_T],
171         getter: Callable[[], Any],
172         attribute: str,
173         new: _T,
174         spec: Any | None,
175         create: bool,
176         spec_set: Any | None,
177         autospec: Any | None,
178         new_callable: Any | None,
179         kwargs: Mapping[str, Any],
180     ) -> None: ...
181     def copy(self) -> _patch[_T]: ...
182     def __call__(self, func: Callable[..., _R]) -> Callable[..., _R]: ...
183     def decorate_class(self, klass: _TT) -> _TT: ...
184     def decorate_callable(self, func: _F) -> _F: ...
185     def get_original(self) -> tuple[Any, bool]: ...
186     target: Any
187     temp_original: Any
188     is_local: bool
189     def __enter__(self) -> _T: ...
190     def __exit__(self, *exc_info: Any) -> None: ...
191     def start(self) -> _T: ...
192     def stop(self) -> None: ...
193
194 class _patch_dict:
195     in_dict: Any
196     values: Any
197     clear: Any
198     def __init__(self, in_dict: Any, values: Any = ..., clear: Any = ..., **kwargs: Any) -> None: ...
199     def __call__(self, f: Any) -> Any: ...
200     def decorate_class(self, klass: Any) -> Any: ...
201     def __enter__(self) -> Any: ...
202     def __exit__(self, *args: Any) -> Any: ...
203     start: Any
204     stop: Any
205
206 class _patcher:
207     TEST_PREFIX: str
208     dict: Type[_patch_dict]
209     @overload
210     def __call__(  # type: ignore
211         self,
212         target: Any,
213         *,
214         spec: Any | None = ...,
215         create: bool = ...,
216         spec_set: Any | None = ...,
217         autospec: Any | None = ...,
218         new_callable: Any | None = ...,
219         **kwargs: Any,
220     ) -> _patch[MagicMock | AsyncMock]: ...
221     # This overload also covers the case, where new==DEFAULT. In this case, the return type is _patch[Any].
222     # Ideally we'd be able to add an overload for it so that the return type is _patch[MagicMock],
223     # but that's impossible with the current type system.
224     @overload
225     def __call__(
226         self,
227         target: Any,
228         new: _T,
229         spec: Any | None = ...,
230         create: bool = ...,
231         spec_set: Any | None = ...,
232         autospec: Any | None = ...,
233         new_callable: Any | None = ...,
234         **kwargs: Any,
235     ) -> _patch[_T]: ...
236     @overload
237     def object(  # type: ignore
238         self,
239         target: Any,
240         attribute: str,
241         *,
242         spec: Any | None = ...,
243         create: bool = ...,
244         spec_set: Any | None = ...,
245         autospec: Any | None = ...,
246         new_callable: Any | None = ...,
247         **kwargs: Any,
248     ) -> _patch[MagicMock | AsyncMock]: ...
249     @overload
250     def object(
251         self,
252         target: Any,
253         attribute: str,
254         new: _T = ...,
255         spec: Any | None = ...,
256         create: bool = ...,
257         spec_set: Any | None = ...,
258         autospec: Any | None = ...,
259         new_callable: Any | None = ...,
260         **kwargs: Any,
261     ) -> _patch[_T]: ...
262     def multiple(
263         self,
264         target: Any,
265         spec: Any | None = ...,
266         create: bool = ...,
267         spec_set: Any | None = ...,
268         autospec: Any | None = ...,
269         new_callable: Any | None = ...,
270         **kwargs: _T,
271     ) -> _patch[_T]: ...
272     def stopall(self) -> None: ...
273
274 patch: _patcher
275
276 class MagicMixin:
277     def __init__(self, *args: Any, **kw: Any) -> None: ...
278
279 class NonCallableMagicMock(MagicMixin, NonCallableMock):
280     def mock_add_spec(self, spec: Any, spec_set: bool = ...) -> None: ...
281
282 class MagicMock(MagicMixin, Mock):
283     def mock_add_spec(self, spec: Any, spec_set: bool = ...) -> None: ...
284
285 class AsyncMockMixin(Base):
286     def __init__(self, *args: Any, **kwargs: Any) -> None: ...
287     async def _execute_mock_call(self, *args: Any, **kwargs: Any) -> Any: ...
288     def assert_awaited(self) -> None: ...
289     def assert_awaited_once(self) -> None: ...
290     def assert_awaited_with(self, *args: Any, **kwargs: Any) -> None: ...
291     def assert_awaited_once_with(self, *args: Any, **kwargs: Any) -> None: ...
292     def assert_any_await(self, *args: Any, **kwargs: Any) -> None: ...
293     def assert_has_awaits(self, calls: _CallList, any_order: bool = ...) -> None: ...
294     def assert_not_awaited(self) -> None: ...
295     def reset_mock(self, *args: Any, **kwargs: Any) -> None: ...
296     await_count: int
297     await_args: _Call | None
298     await_args_list: _CallList
299
300 class AsyncMagicMixin(MagicMixin):
301     def __init__(self, *args: Any, **kw: Any) -> None: ...
302
303 class AsyncMock(AsyncMockMixin, AsyncMagicMixin, Mock): ...
304
305 class MagicProxy:
306     name: Any
307     parent: Any
308     def __init__(self, name: Any, parent: Any) -> None: ...
309     def __call__(self, *args: Any, **kwargs: Any) -> Any: ...
310     def create_mock(self) -> Any: ...
311     def __get__(self, obj: Any, _type: Any | None = ...) -> Any: ...
312
313 class _ANY:
314     def __eq__(self, other: Any) -> bool: ...
315     def __ne__(self, other: Any) -> bool: ...
316
317 ANY: Any
318
319 def create_autospec(
320     spec: Any, spec_set: Any = ..., instance: Any = ..., _parent: Any | None = ..., _name: Any | None = ..., **kwargs: Any
321 ) -> Any: ...
322
323 class _SpecState:
324     spec: Any
325     ids: Any
326     spec_set: Any
327     parent: Any
328     instance: Any
329     name: Any
330     def __init__(
331         self,
332         spec: Any,
333         spec_set: Any = ...,
334         parent: Any | None = ...,
335         name: Any | None = ...,
336         ids: Any | None = ...,
337         instance: Any = ...,
338     ) -> None: ...
339
340 def mock_open(mock: Any | None = ..., read_data: Any = ...) -> Any: ...
341
342 PropertyMock = Any
343
344 def seal(mock: Any) -> None: ...