Restore stubtest 0.930 (#6663)

This commit is contained in:
Sebastian Rittau
2021-12-23 05:18:19 +01:00
committed by GitHub
parent 9bf2ceb963
commit 3fb2bcd4c1
51 changed files with 478 additions and 123 deletions

View File

@@ -5,23 +5,57 @@ _T = TypeVar("_T")
_TT = TypeVar("_TT", bound=Type[Any])
_R = TypeVar("_R")
__all__ = [
"Mock",
"MagicMock",
"patch",
"sentinel",
"DEFAULT",
"ANY",
"call",
"create_autospec",
"AsyncMock",
"FILTER_DIR",
"NonCallableMock",
"NonCallableMagicMock",
"mock_open",
"PropertyMock",
"seal",
]
if sys.version_info >= (3, 8):
__all__ = (
"Mock",
"MagicMock",
"patch",
"sentinel",
"DEFAULT",
"ANY",
"call",
"create_autospec",
"AsyncMock",
"FILTER_DIR",
"NonCallableMock",
"NonCallableMagicMock",
"mock_open",
"PropertyMock",
"seal",
)
elif sys.version_info >= (3, 7):
__all__ = (
"Mock",
"MagicMock",
"patch",
"sentinel",
"DEFAULT",
"ANY",
"call",
"create_autospec",
"FILTER_DIR",
"NonCallableMock",
"NonCallableMagicMock",
"mock_open",
"PropertyMock",
"seal",
)
else:
__all__ = (
"Mock",
"MagicMock",
"patch",
"sentinel",
"DEFAULT",
"ANY",
"call",
"create_autospec",
"FILTER_DIR",
"NonCallableMock",
"NonCallableMagicMock",
"mock_open",
"PropertyMock",
)
__version__: str
FILTER_DIR: Any
@@ -39,7 +73,7 @@ class _Sentinel:
sentinel: Any
DEFAULT: Any
class _Call(Tuple[Any, ...]):
class _Call(tuple[Any, ...]):
def __new__(
cls, value: Any = ..., name: Any | None = ..., parent: Any | None = ..., two: bool = ..., from_kall: bool = ...
) -> Any: ...
@@ -53,6 +87,11 @@ class _Call(Tuple[Any, ...]):
__ne__: Any
def __call__(self, *args: Any, **kwargs: Any) -> _Call: ...
def __getattr__(self, attr: Any) -> Any: ...
if sys.version_info >= (3, 8):
@property
def args(self): ...
@property
def kwargs(self): ...
def call_list(self) -> Any: ...
call: _Call
@@ -60,12 +99,6 @@ call: _Call
class _CallList(List[_Call]):
def __contains__(self, value: Any) -> bool: ...
class _MockIter:
obj: Any
def __init__(self, obj: Any) -> None: ...
def __iter__(self) -> Any: ...
def __next__(self) -> Any: ...
class Base:
def __init__(self, *args: Any, **kwargs: Any) -> None: ...
@@ -141,7 +174,10 @@ class CallableMixin(Base):
_new_parent: Any | None = ...,
**kwargs: Any,
) -> None: ...
def __call__(_mock_self, *args: Any, **kwargs: Any) -> Any: ...
if sys.version_info >= (3, 8):
def __call__(self, *args: Any, **kwargs: Any) -> Any: ...
else:
def __call__(_mock_self, *args: Any, **kwargs: Any) -> Any: ...
class Mock(CallableMixin, NonCallableMock): ...
@@ -160,23 +196,41 @@ class _patch(Generic[_T]):
additional_patchers: Any
# If new==DEFAULT, self is _patch[Any]. Ideally we'd be able to add an overload for it so that self is _patch[MagicMock],
# but that's impossible with the current type system.
def __init__(
self: _patch[_T],
getter: Callable[[], Any],
attribute: str,
new: _T,
spec: Any | None,
create: bool,
spec_set: Any | None,
autospec: Any | None,
new_callable: Any | None,
kwargs: Mapping[str, Any],
) -> None: ...
if sys.version_info >= (3, 10):
def __init__(
self: _patch[_T],
getter: Callable[[], Any],
attribute: str,
new: _T,
spec: Any | None,
create: bool,
spec_set: Any | None,
autospec: Any | None,
new_callable: Any | None,
kwargs: Mapping[str, Any],
*,
unsafe: bool = ...,
) -> None: ...
else:
def __init__(
self: _patch[_T],
getter: Callable[[], Any],
attribute: str,
new: _T,
spec: Any | None,
create: bool,
spec_set: Any | None,
autospec: Any | None,
new_callable: Any | None,
kwargs: Mapping[str, Any],
) -> None: ...
def copy(self) -> _patch[_T]: ...
@overload
def __call__(self, func: _TT) -> _TT: ...
@overload
def __call__(self, func: Callable[..., _R]) -> Callable[..., _R]: ...
if sys.version_info >= (3, 8):
def decoration_helper(self, patched, args, keywargs): ...
def decorate_class(self, klass: _TT) -> _TT: ...
def decorate_callable(self, func: Callable[..., _R]) -> Callable[..., _R]: ...
if sys.version_info >= (3, 8):
@@ -357,10 +411,11 @@ if sys.version_info >= (3, 8):
class MagicProxy:
name: Any
parent: Any
def __init__(self, name: Any, parent: Any) -> None: ...
def __call__(self, *args: Any, **kwargs: Any) -> Any: ...
def create_mock(self) -> Any: ...
def __get__(self, obj: Any, _type: Any | None = ...) -> Any: ...
def __init__(self, name, parent) -> 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 = ...): ...
class _ANY:
def __eq__(self, other: Any) -> bool: ...