[pygrep_hooks] Add AsyncMock methods to invalid-mock-access (PGH005) by robsdedude · Pull Request #18547 · astral-sh/ruff (original) (raw)
Conversation
Summary
This PR expands PGH005 to also check for AsyncMock methods in the same vein. E.g., currently assert mock.not_called is linted. This PR adds the corresponding async assertions assert mock.not_awaited().
| | "called_with" |
|---|
| | "has_calls" |
| | "not_called" |
| | "awaited" |
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().
ruff-ecosystem results
Linter (stable)
✅ ecosystem check detected no linter changes.
Linter (preview)
✅ ecosystem check detected no linter changes.
Implementing or modifying a lint rule
label
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
ntBre changed the title
[ [pygrep_hooks] add AsyncMock methods to invalid-mock-access (PGH005)pygrep_hooks] Add AsyncMock methods to invalid-mock-access (PGH005)
robsdedude deleted the feat/pgh005-add-async-mock-methods branch
dylwil3 added a commit that referenced this pull request
…access (PGH005`) (#20272)
Introduced in #18547. Removed gating, updated tests. Not documented so documentation is the same.
ntBre pushed a commit that referenced this pull request
…access (PGH005`) (#20272)
Introduced in #18547. Removed gating, updated tests. Not documented so documentation is the same.
ntBre pushed a commit that referenced this pull request
…access (PGH005`) (#20272)
Introduced in #18547. Removed gating, updated tests. Not documented so documentation is the same.
ntBre pushed a commit that referenced this pull request
…access (PGH005`) (#20272)
Introduced in #18547. Removed gating, updated tests. Not documented so documentation is the same.
ntBre pushed a commit that referenced this pull request
…access (PGH005`) (#20272)
Introduced in #18547. Removed gating, updated tests. Not documented so documentation is the same.
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
[ Show hidden characters]({{ revealButtonHref }})
Labels
Related to preview mode features
Implementing or modifying a lint rule