ruff/crates/ruff_linter
Roman Kitaev b0f01ba514
[`flake8-blind-except`] Change `BLE001` to correctly parse exception tuples (#19747)
## Summary

This PR enhances the `BLE001` rule to correctly detect blind exception
handling in tuple exceptions. Previously, the rule only checked single
exception types, but Python allows catching multiple exceptions using
tuples like `except (Exception, ValueError):`.

## Test Plan

It fails the following (whereas the main branch does not):

```bash
cargo run -p ruff -- check somefile.py --no-cache --select=BLE001
```

```python
# somefile.py

try:
    1/0
except (ValueError, Exception) as e:
    print(e)
```

```
somefile.py:3:21: BLE001 Do not catch blind exception: `Exception`
  |
1 | try:
2 |     1/0
3 | except (ValueError, Exception) as e:
  |                     ^^^^^^^^^ BLE001
4 |     print(e)
  |

Found 1 error.
```
2025-08-04 21:12:45 +00:00
..
resources [`flake8-blind-except`] Change `BLE001` to correctly parse exception tuples (#19747) 2025-08-04 21:12:45 +00:00
src [`flake8-blind-except`] Change `BLE001` to correctly parse exception tuples (#19747) 2025-08-04 21:12:45 +00:00
Cargo.toml Bump 0.12.7 (#19627) 2025-07-29 18:18:42 -04:00