Skip to content

Fix patch.object to return a _patch context manager. #1142

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 2 commits into from
Apr 7, 2017

Conversation

rowillia
Copy link
Contributor

@rowillia rowillia commented Apr 5, 2017

This should fix #914

@rowillia rowillia force-pushed the fix_patch_object branch 3 times, most recently from eb798b9 to b1fedfc Compare April 5, 2017 22:05
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 _patcher:
def __call__(self, target: Any, new: Any =..., spec: Any = None, create: Any = False, spec_set: Any = None, autospec: Any = None, new_callable: Any = None, **kwargs: Any) -> Any: ...
def object(self, target: Any, attribute: str, new: Any =..., spec: Any = None, create: Any = False, spec_set: Any = None, autospec: Any = None, new_callable: Any = None, **kwargs: Any) -> _patch: ...
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're using = None in some places, and = ... in others.

I generally prefer the latter, but at the very least, it should be consistent within the same file.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, x: t = None really means x: Optional[t] = None, and in modern mypy Optional[Any] is not the same as Any. So beware.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the feedback @matthiaskramm and @gvanrossum ! I wound up using None to be consistent with the other call sites with a similar signature in this file.

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.

patch.object throws error
3 participants