ruff
b0f01ba5 - [`flake8-blind-except`] Change `BLE001` to correctly parse exception tuples (#19747)

Commit
61 days ago
[`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. ```
Author
Parents
Loading