From 51ebff7e416212ad0c10290ba9cd82d6a9b7781c Mon Sep 17 00:00:00 2001 From: Harutaka Kawamura Date: Mon, 24 Jul 2023 10:43:18 +0900 Subject: [PATCH] Add `PT010` doc (#6010) --- .../rules/flake8_pytest_style/rules/raises.rs | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) 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;