ruff/crates/ruff_linter
Roman Kitaev df0648aae0
[flake8-blind-except] Fix BLE001 false-positive on raise ... from None (#19755)
## Summary

- Refactored `BLE001` logic for clarity and minor speed-up.
- Improved documentation and comments (previously, `BLE001` docs claimed
it catches bare `except:`s, but it doesn't).
- Fixed a false-positive bug with `from None` cause:

```python
# somefile.py

try:
    pass
except BaseException as e:
    raise e from None
```

### main branch
```
somefile.py:3:8: BLE001 Do not catch blind exception: `BaseException`
  |
1 | try:
2 |     pass
3 | except BaseException as e:
  |        ^^^^^^^^^^^^^ BLE001
4 |     raise e from None
  |

Found 1 error.
```

### this change

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

```
All checks passed!
```

## Test Plan

- Added a test case to cover `raise X from Y` clause
- Added a test case to cover `raise X from None` clause
2025-08-13 13:01:47 -04:00
..
resources [flake8-blind-except] Fix BLE001 false-positive on raise ... from None (#19755) 2025-08-13 13:01:47 -04:00
src [flake8-blind-except] Fix BLE001 false-positive on raise ... from None (#19755) 2025-08-13 13:01:47 -04:00
Cargo.toml Clean up unused rendering code in ruff_linter (#19832) 2025-08-09 14:20:48 -04:00