ruff
cbc71c28 - [`ruff`] Avoid false positive when `pytest.raises` is used in a `with` statement (`RUF061`) (#28186)

Commit
12 days ago
[`ruff`] Avoid false positive when `pytest.raises` is used in a `with` statement (`RUF061`) (#28186) ## Summary Closes #28146. Avoids false-positive `RUF061` violations when `pytest.raises(...)`, `pytest.warns(...)`, or `pytest.deprecated_call(...)` is already used as the context expression in a `with` (or `async with`) statement. Previously, passing additional positional arguments (such as `with pytest.raises(ValueError, "oops"):`) caused `find_argument("func", 1)` to match the second positional argument as the deprecated callable parameter, triggering `RUF061` on code that was already using context-manager syntax. ## Test Plan - Updated `RUF061_raises.py`, `RUF061_warns.py`, and `RUF061_deprecated_call.py` with test cases covering extra positional arguments in `with` statements and nested calls within `with` bodies. - Updated snapshots via `INSTA_UPDATE=always cargo test -p ruff_linter`. - Verified `cargo fmt --check` and `cargo clippy -p ruff_linter --all-targets`. --------- Co-authored-by: Brent Westbrook <brentrwestbrook@gmail.com>
Author
Parents
Loading