-
Notifications
You must be signed in to change notification settings - Fork 1.6k
[pygrep_hooks] Add AsyncMock methods to invalid-mock-access (PGH005)
#18547
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
[pygrep_hooks] Add AsyncMock methods to invalid-mock-access (PGH005)
#18547
Conversation
| | "called_with" | ||
| | "has_calls" | ||
| | "not_called" | ||
| | "awaited" |
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.
N.B., the sync equivalent called is not in this list. That is because (sync) Mocks have a boolean attribute called. However, AsyncMocks do not have an attribute awaited. Therefore, assert mock.awaited is likely a mistake and was meant to be mock.assert_awaited().
|
ntBre
left a comment
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.
Makes sense, thanks! Just one tiny suggestion to include the URL for the PR on the preview function.
Co-authored-by: Brent Westbrook <36778786+ntBre@users.noreply.github.com>
pygrep_hooks] add AsyncMock methods to invalid-mock-access (PGH005)pygrep_hooks] Add AsyncMock methods to invalid-mock-access (PGH005)
Summary
This PR expands PGH005 to also check for AsyncMock methods in the same vein. E.g., currently
assert mock.not_calledis linted. This PR adds the corresponding async assertionsassert mock.not_awaited().