Fix unittest/mock.pyi - #973
Merged
Merged
Conversation
Add a lot of missing types
| 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: ... |
Member
There was a problem hiding this comment.
I think typeshed style puts a space after : and around every =.
Member
There was a problem hiding this comment.
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): |
Member
There was a problem hiding this comment.
Inheriting from Any is an interesting choice. I'm not sure what type checkers will make of it.
Contributor
Author
There was a problem hiding this comment.
It's the only way I was able to
- Have a separate type
Mock, i.e. definingMockas type in functions - Passing an instance of
Mockto functions expecting other classes (i.e. using the mock for its purpose)
|
|
||
| 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: ... |
Member
There was a problem hiding this comment.
two and from_kall can be typed as bool I think.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add a lot of missing types