Add missing typings to unittest.mock (#7431)

This commit is contained in:
Itai Steinherz
2022-03-07 01:43:39 +02:00
committed by GitHub
parent bc72b25a2a
commit b9909b121e
2 changed files with 17 additions and 11 deletions

View File

@@ -13,7 +13,6 @@
"stdlib/sqlite3/dbapi2.pyi",
"stdlib/_tkinter.pyi",
"stdlib/tkinter",
"stdlib/unittest/mock.pyi",
"stdlib/xml/dom/NodeFilter.pyi",
"stdlib/xml/dom/expatbuilder.pyi",
"stdlib/xml/dom/minidom.pyi",

View File

@@ -1,5 +1,6 @@
import sys
from _typeshed import Self
from contextlib import _GeneratorContextManager
from typing import Any, Awaitable, Callable, Generic, Iterable, Mapping, Sequence, TypeVar, overload
from typing_extensions import Literal
@@ -75,11 +76,15 @@ class _Sentinel:
sentinel: Any
DEFAULT: Any
_ArgsKwargs = tuple[tuple[Any, ...], Mapping[str, Any]]
_NameArgsKwargs = tuple[str, tuple[Any, ...], Mapping[str, Any]]
_CallValue = str | tuple[Any, ...] | Mapping[str, Any] | _ArgsKwargs | _NameArgsKwargs
class _Call(tuple[Any, ...]):
def __new__(
cls: type[Self],
value: Any = ...,
name: Any | None = ...,
value: _CallValue = ...,
name: str | None = ...,
parent: Any | None = ...,
two: bool = ...,
from_kall: bool = ...,
@@ -88,7 +93,7 @@ class _Call(tuple[Any, ...]):
parent: Any
from_kall: Any
def __init__(
self, value: Any = ..., name: Any | None = ..., parent: Any | None = ..., two: bool = ..., from_kall: bool = ...
self, value: _CallValue = ..., name: str | None = ..., parent: Any | None = ..., two: bool = ..., from_kall: bool = ...
) -> None: ...
def __eq__(self, other: object) -> bool: ...
def __ne__(self, __other: object) -> bool: ...
@@ -97,9 +102,9 @@ class _Call(tuple[Any, ...]):
def __getattribute__(self, attr: str) -> Any: ...
if sys.version_info >= (3, 8):
@property
def args(self): ...
def args(self) -> tuple[Any, ...]: ...
@property
def kwargs(self): ...
def kwargs(self) -> Mapping[str, Any]: ...
def call_list(self) -> Any: ...
@@ -244,7 +249,9 @@ class _patch(Generic[_T]):
@overload
def __call__(self, func: Callable[..., _R]) -> Callable[..., _R]: ...
if sys.version_info >= (3, 8):
def decoration_helper(self, patched, args, keywargs): ...
def decoration_helper(
self, patched: _patch[Any], args: Sequence[Any], keywargs: Any
) -> _GeneratorContextManager[tuple[Sequence[Any], Any]]: ...
def decorate_class(self, klass: _TT) -> _TT: ...
def decorate_callable(self, func: Callable[..., _R]) -> Callable[..., _R]: ...
@@ -428,14 +435,14 @@ if sys.version_info >= (3, 8):
class AsyncMock(AsyncMockMixin, AsyncMagicMixin, Mock): ... # type: ignore # argument disparities between base classes
class MagicProxy:
name: Any
name: str
parent: Any
def __init__(self, name, parent) -> None: ...
def __init__(self, name: str, parent: Any) -> None: ...
if sys.version_info < (3, 8):
def __call__(self, *args: Any, **kwargs: Any) -> Any: ...
def create_mock(self): ...
def __get__(self, obj, _type: Any | None = ...): ...
def create_mock(self) -> Any: ...
def __get__(self, obj: Any, _type: Any | None = ...) -> Any: ...
class _ANY:
def __eq__(self, other: object) -> Literal[True]: ...