From c98ea1bc2438ef592d423afcb24c17fc11605591 Mon Sep 17 00:00:00 2001 From: Harutaka Kawamura Date: Wed, 14 Jan 2026 05:45:53 +0900 Subject: [PATCH] [`flake8-pytest-style`] Add `check` parameter example to `PT017` docs (#22546) ## Summary - Adds an alternative example to the PT017 (`pytest-assert-in-except`) rule documentation showing pytest's `check` parameter for validating exceptions, available since pytest 8.4.0 Closes #22529 ## Test plan Documentation-only change. Verified with `uvx prek run -a`. Co-authored-by: Claude Opus 4.5 --- .../src/rules/flake8_pytest_style/rules/assertion.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/crates/ruff_linter/src/rules/flake8_pytest_style/rules/assertion.rs b/crates/ruff_linter/src/rules/flake8_pytest_style/rules/assertion.rs index c97efd8b05..9b82d8eb95 100644 --- a/crates/ruff_linter/src/rules/flake8_pytest_style/rules/assertion.rs +++ b/crates/ruff_linter/src/rules/flake8_pytest_style/rules/assertion.rs @@ -106,6 +106,16 @@ impl Violation for PytestCompositeAssertion { /// assert exc_info.value.args /// ``` /// +/// Or, for pytest 8.4.0 and later: +/// ```python +/// import pytest +/// +/// +/// def test_foo(): +/// with pytest.raises(ZeroDivisionError, check=lambda e: e.args): +/// 1 / 0 +/// ``` +/// /// ## References /// - [`pytest` documentation: `pytest.raises`](https://docs.pytest.org/en/latest/reference/reference.html#pytest-raises) #[derive(ViolationMetadata)]