Skip to content

Conversation

@robsdedude
Copy link
Contributor

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"
Copy link
Contributor Author

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().

@github-actions
Copy link
Contributor

github-actions bot commented Jun 8, 2025

ruff-ecosystem results

Linter (stable)

✅ ecosystem check detected no linter changes.

Linter (preview)

✅ ecosystem check detected no linter changes.

@ntBre ntBre added the rule Implementing or modifying a lint rule label Jun 9, 2025
Copy link
Contributor

@ntBre ntBre left a 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.

@ntBre ntBre added the preview Related to preview mode features label Jun 18, 2025
robsdedude and others added 2 commits June 24, 2025 20:13
Co-authored-by: Brent Westbrook <36778786+ntBre@users.noreply.github.com>
@ntBre ntBre changed the title [pygrep_hooks] add AsyncMock methods to invalid-mock-access (PGH005) [pygrep_hooks] Add AsyncMock methods to invalid-mock-access (PGH005) Jun 24, 2025
@ntBre ntBre merged commit 919af96 into astral-sh:main Jun 24, 2025
35 checks passed
@robsdedude robsdedude deleted the feat/pgh005-add-async-mock-methods branch June 24, 2025 21:32
dylwil3 added a commit that referenced this pull request Sep 8, 2025
…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 Sep 8, 2025
…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 Sep 10, 2025
…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 Sep 10, 2025
…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 Sep 10, 2025
…access` (`PGH005`) (#20272)

Introduced in #18547. Removed gating, updated tests. Not documented so
documentation is the same.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

preview Related to preview mode features rule Implementing or modifying a lint rule

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants