Skip to content

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

Merged
merged 5 commits into from
Mar 8, 2017
Merged

Fix unittest/mock.pyi #973

merged 5 commits into from
Mar 8, 2017

Conversation

smessmer
Copy link
Contributor

@smessmer smessmer commented Mar 6, 2017

Add a lot of missing types

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: ...
Copy link
Member

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 =.

Copy link
Member

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):
Copy link
Member

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.

Copy link
Contributor Author

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. defining Mock as type in functions
  • Passing an instance of Mock to functions expecting other classes (i.e. using the mock for its purpose)


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: ...
Copy link
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants