diff --git a/crates/ruff/src/rules/flake8_pytest_style/rules/raises.rs b/crates/ruff/src/rules/flake8_pytest_style/rules/raises.rs index 129d9bcb74..c4d45e2bd2 100644 --- a/crates/ruff/src/rules/flake8_pytest_style/rules/raises.rs +++ b/crates/ruff/src/rules/flake8_pytest_style/rules/raises.rs @@ -38,6 +38,35 @@ impl Violation for PytestRaisesTooBroad { } } +/// ## What it does +/// Checks for `pytest.raises` calls without an expected exception. +/// +/// ## Why is this bad? +/// `pytest.raises` expects to receive an expected exception as its first +/// argument. If omitted, the `pytest.raises` call will fail at runtime. +/// +/// ## Example +/// ```python +/// import pytest +/// +/// +/// def test_foo(): +/// with pytest.raises(): +/// do_something() +/// ``` +/// +/// Use instead: +/// ```python +/// import pytest +/// +/// +/// def test_foo(): +/// with pytest.raises(SomeException): +/// do_something() +/// ``` +/// +/// ## References +/// - [API Reference: `pytest.raises`](https://docs.pytest.org/en/latest/reference/reference.html#pytest-raises) #[violation] pub struct PytestRaisesWithoutException;