diff --git a/stdlib/3/unittest/mock.pyi b/stdlib/3/unittest/mock.pyi index 3d54fe938cd7..5a3f6b00f0c7 100644 --- a/stdlib/3/unittest/mock.pyi +++ b/stdlib/3/unittest/mock.pyi @@ -10,35 +10,34 @@ if sys.version_info >= (3, 3): class _SentinelObject: name = ... # type: Any - def __init__(self, name): ... + def __init__(self, name: Any) -> None: ... class _Sentinel: - def __init__(self): ... - def __getattr__(self, name): ... + def __init__(self) -> None: ... + def __getattr__(self, name: str) -> Any: ... sentinel = ... # type: Any DEFAULT = ... # type: Any class _CallList(list): - def __contains__(self, value): ... + def __contains__(self, value: Any) -> bool: ... class _MockIter: obj = ... # type: Any - def __init__(self, obj): ... - def __iter__(self): ... - def __next__(self): ... + def __init__(self, obj: Any) -> None: ... + def __iter__(self) -> Any: ... + def __next__(self) -> Any: ... class Base: - def __init__(self, *args, **kwargs): ... + def __init__(self, *args: Any, **kwargs: Any) -> None: ... - class NonCallableMock(Base): - def __new__(cls, *args, **kw): ... - def __init__(self, spec=None, wraps=None, name=None, spec_set=None, parent=None, _spec_state=None, _new_name='', _new_parent=None, _spec_as_instance=False, _eat_self=None, unsafe=False, **kwargs): ... - def attach_mock(self, mock, attribute): ... - def mock_add_spec(self, spec, spec_set=False): ... + class NonCallableMock(Any): + def __new__(cls, *args: Any, **kw: Any) -> Any: ... + def __init__(self, spec: Any = None, wraps: Any = None, name: Any = None, spec_set: Any = None, parent: Any = None, _spec_state: Any = None, _new_name: Any ='', _new_parent: Any = None, _spec_as_instance: Any = False, _eat_self: Any = None, unsafe: Any = False, **kwargs: Any) -> None: ... + def attach_mock(self, mock: Any, attribute: Any) -> Any: ... + def mock_add_spec(self, spec: Any, spec_set: Any = False) -> Any: ... return_value = ... # type: Any - @property - def __class__(self): ... + __class__ = ... # type: type called = ... # type: Any call_count = ... # type: Any call_args = ... # type: Any @@ -46,24 +45,25 @@ if sys.version_info >= (3, 3): mock_calls = ... # type: Any side_effect = ... # type: Any method_calls = ... # type: Any - def reset_mock(self, visited=None): ... - def configure_mock(self, **kwargs): ... - def __getattr__(self, name): ... - def __dir__(self): ... - def __setattr__(self, name, value): ... - def __delattr__(self, name): ... - def assert_not_called(_mock_self): ... - def assert_called_with(_mock_self, *args, **kwargs): ... - def assert_called_once_with(_mock_self, *args, **kwargs): ... - def assert_has_calls(self, calls, any_order=False): ... - def assert_any_call(self, *args, **kwargs): ... + def reset_mock(self, visited: bool = None) -> None: ... + def configure_mock(self, **kwargs: Any) -> None: ... + def __getattr__(self, name: Any) -> Any: ... + def __dir__(self) -> Any: ... + def __setattr__(self, name: Any, value: Any) -> None: ... + def __delattr__(self, name: Any) -> None: ... + def assert_not_called(_mock_self) -> None: ... + def assert_called_with(_mock_self, *args: Any, **kwargs: Any) -> None: ... + def assert_called_once_with(_mock_self, *args: Any, **kwargs: Any) -> None: ... + def assert_has_calls(self, calls: Any, any_order: bool = False) -> None: ... + def assert_any_call(self, *args: Any, **kwargs: Any) -> None: ... class CallableMixin(Base): side_effect = ... # type: Any - def __init__(self, spec=None, side_effect=None, return_value=..., wraps=None, name=None, spec_set=None, parent=None, _spec_state=None, _new_name='', _new_parent=None, **kwargs): ... - def __call__(_mock_self, *args, **kwargs): ... + def __init__(self, spec: Any = None, side_effect: Any = None, return_value: Any = ..., wraps: Any = None, name: Any = None, spec_set: Any = None, parent: Any = None, _spec_state: Any = None, _new_name: Any = '', _new_parent: Any = None, **kwargs: Any) -> None: ... + def __call__(_mock_self, *args: Any, **kwargs: Any) -> Any: ... - class Mock(CallableMixin, NonCallableMock): ... + class Mock(CallableMixin, NonCallableMock): + def __init__(self) -> None: ... class _patch: attribute_name = ... # type: Any @@ -78,74 +78,76 @@ if sys.version_info >= (3, 3): autospec = ... # type: Any kwargs = ... # type: Any additional_patchers = ... # type: Any - def __init__(self, getter, attribute, new, spec, create, spec_set, autospec, new_callable, kwargs): ... - def copy(self): ... - def __call__(self, func): ... - def decorate_class(self, klass): ... - def decorate_callable(self, func): ... - def get_original(self): ... + def __init__(self, getter: Any, attribute: Any, new: Any, spec: Any, create: Any, spec_set: Any, autospec: Any, new_callable: Any, kwargs: Any) -> None: ... + def copy(self) -> Any: ... + def __call__(self, func: Any) -> Any: ... + def decorate_class(self, klass: Any) -> Any: ... + def decorate_callable(self, func: Any) -> Any: ... + def get_original(self) -> Any: ... target = ... # type: Any temp_original = ... # type: Any is_local = ... # type: Any - def __enter__(self): ... - def __exit__(self, *exc_info): ... - def start(self): ... - def stop(self): ... + def __enter__(self) -> Any: ... + def __exit__(self, *exc_info: Any) -> Any: ... + def start(self) -> Any: ... + def stop(self) -> Any: ... - def patch(target, new=..., spec=None, create=False, spec_set=None, autospec=None, new_callable=None, **kwargs): ... + def patch(target: Any, new: Any =..., spec: Any = None, create: Any = False, spec_set: Any = None, autospec: Any = None, new_callable: Any = None, **kwargs: Any) -> Any: ... class _patch_dict: in_dict = ... # type: Any values = ... # type: Any clear = ... # type: Any - def __init__(self, in_dict, values=..., clear=False, **kwargs): ... - def __call__(self, f): ... - def decorate_class(self, klass): ... - def __enter__(self): ... - def __exit__(self, *args): ... + def __init__(self, in_dict: Any, values: Any = ..., clear: Any = False, **kwargs: Any) -> None: ... + def __call__(self, f: Any) -> Any: ... + def decorate_class(self, klass: Any) -> Any: ... + def __enter__(self) -> Any: ... + def __exit__(self, *args: Any) -> Any: ... start = ... # type: Any stop = ... # type: Any class MagicMixin: - def __init__(self, *args, **kw): ... + def __init__(self, *args: Any, **kw: Any) -> None: ... class NonCallableMagicMock(MagicMixin, NonCallableMock): - def mock_add_spec(self, spec, spec_set=False): ... + def __init__(self) -> None: ... + def mock_add_spec(self, spec: Any, spec_set: Any = False) -> Any: ... class MagicMock(MagicMixin, Mock): - def mock_add_spec(self, spec, spec_set=False): ... + def __init__(self) -> None: ... + def mock_add_spec(self, spec: Any, spec_set: Any = False) -> Any: ... class MagicProxy: name = ... # type: Any parent = ... # type: Any - def __init__(self, name, parent): ... - def __call__(self, *args, **kwargs): ... - def create_mock(self): ... - def __get__(self, obj, _type=None): ... + 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: ... class _ANY: - def __eq__(self, other): ... - def __ne__(self, other): ... + def __eq__(self, other: Any) -> bool: ... + def __ne__(self, other: Any) -> bool: ... ANY = ... # type: Any class _Call(tuple): - def __new__(cls, value=..., name=None, parent=None, two=False, from_kall=True): ... + def __new__(cls, value: Any = ..., name: Any = None, parent: Any = None, two: bool = False, from_kall: bool = True) -> Any: ... name = ... # type: Any parent = ... # type: Any from_kall = ... # type: Any - def __init__(self, value=..., name=None, parent=None, two=False, from_kall=True): ... - def __eq__(self, other): ... + def __init__(self, value: Any = ..., name: Any = None, parent: Any = None, two: bool = False, from_kall: bool = True) -> None: ... + def __eq__(self, other: Any) -> bool: ... __ne__ = ... # type: Any - def __call__(self, *args, **kwargs): ... - def __getattr__(self, attr): ... - def count(self, *args, **kwargs): ... - def index(self, *args, **kwargs): ... - def call_list(self): ... + def __call__(self, *args: Any, **kwargs: Any) -> Any: ... + def __getattr__(self, attr: Any) -> Any: ... + def count(self, *args: Any, **kwargs: Any) -> Any: ... + def index(self, *args: Any, **kwargs: Any) -> Any: ... + def call_list(self) -> Any: ... call = ... # type: Any - def create_autospec(spec, spec_set=False, instance=False, _parent=None, _name=None, **kwargs): ... + def create_autospec(spec: Any, spec_set: Any = False, instance: Any = False, _parent: Any = None, _name: Any = None, **kwargs: Any) -> Any: ... class _SpecState: spec = ... # type: Any @@ -154,10 +156,10 @@ if sys.version_info >= (3, 3): parent = ... # type: Any instance = ... # type: Any name = ... # type: Any - def __init__(self, spec, spec_set=False, parent=None, name=None, ids=None, instance=False): ... + def __init__(self, spec: Any, spec_set: Any = False, parent: Any = None, name: Any = None, ids: Any = None, instance: Any = False) -> None: ... - def mock_open(mock=None, read_data=''): ... + def mock_open(mock: Any = None, read_data: Any = '') -> Any: ... class PropertyMock(Mock): - def __get__(self, obj, obj_type): ... - def __set__(self, obj, val): ... + def __get__(self, obj: Any, obj_type: Any) -> Any: ... + def __set__(self, obj: Any, val: Any) -> Any: ...