Skip to content

Conversation

@mahiro72
Copy link
Contributor

Summary

Updates PT010(pytest-raises-without-exception) to recognize match and check keyword arguments as valid alternatives to specifying an exception class.

As of pytest 8.4.0, pytest.raises() can be called with only match or check keyword arguments without an expected exception.

Fixes #18653

Test Plan

  • Added test cases for match-only, check-only, and both arguments.
  • cargo test -p ruff_linter -- "pytestraiseswithoutexception" passes

@astral-sh-bot
Copy link

astral-sh-bot bot commented Dec 13, 2025

ruff-ecosystem results

Linter (stable)

✅ ecosystem check detected no linter changes.

Linter (preview)

✅ ecosystem check detected no linter changes.

@mahiro72 mahiro72 marked this pull request as ready for review December 13, 2025 19:00
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.

Looks great, thank you! I just had one nit about the docs.

I also thought a bit about making this a preview change in case people had previously had noqa comments like:

with pytest.raises(match="some pattern"):  # noqa: PT010

but I didn't find any examples of that in a GitHub code search, and the ecosystem check is obviously clean, so I think it's okay to land in stable.

@ntBre ntBre added the rule Implementing or modifying a lint rule label Dec 17, 2025
@ntBre ntBre changed the title [PT010] Allow match and check keyword arguments without exception class (pytest 8.4.0+) [flake8-pytest-style] Allow match and check keyword arguments without an expected exception type (PT010) Dec 17, 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.

Thank you!

@ntBre ntBre merged commit 10748b2 into astral-sh:main Dec 18, 2025
37 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

rule Implementing or modifying a lint rule

Projects

None yet

Development

Successfully merging this pull request may close these issues.

PT010 should be updated for pytest 8.4.0

2 participants