-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Fix unittest/mock.pyi #973
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Add a lot of missing types
stdlib/3/unittest/mock.pyi
Outdated
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: ... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think typeshed style puts a space after : and around every =.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, that's in PEP 8 (and the examples in PEP 484 are also formatted that way).
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): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Inheriting from Any is an interesting choice. I'm not sure what type checkers will make of it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's the only way I was able to
- Have a separate type
Mock
, i.e. definingMock
as type in functions - Passing an instance of
Mock
to functions expecting other classes (i.e. using the mock for its purpose)
stdlib/3/unittest/mock.pyi
Outdated
|
||
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:Any=False, from_kall:Any=True)->Any: ... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
two
and from_kall
can be typed as bool
I think.
Add a lot of missing types