[flake8-blind-except] Change BLE001 to correctly parse exception tuples#19747
Merged
dylwil3 merged 1 commit intoastral-sh:mainfrom Aug 4, 2025
Merged
[flake8-blind-except] Change BLE001 to correctly parse exception tuples#19747dylwil3 merged 1 commit intoastral-sh:mainfrom
flake8-blind-except] Change BLE001 to correctly parse exception tuples#19747dylwil3 merged 1 commit intoastral-sh:mainfrom
Conversation
63115c7 to
5620d2f
Compare
lake8-blind-except] Change BLE001 to correctly parse exception tuples
dylwil3
requested changes
Aug 4, 2025
Collaborator
dylwil3
left a comment
There was a problem hiding this comment.
Neat, thank you! I'm gonna call this a bug instead of an extension of the rule - I don't think it needs to be gated behind preview. Let's just add a couple more tests - the implementation looks good to me though!
Contributor
|
| code | total | + violation | - violation | + fix | - fix |
|---|---|---|---|---|---|
| BLE001 | 3 | 3 | 0 | 0 | 0 |
Linter (preview)
ℹ️ ecosystem check detected linter changes. (+3 -0 violations, +0 -0 fixes in 2 projects; 53 projects unchanged)
apache/airflow (+2 -0 violations, +0 -0 fixes)
ruff check --no-cache --exit-zero --ignore RUF9 --no-fix --output-format concise --preview --select ALL
+ airflow-core/src/airflow/models/dagbundle.py:74:31: BLE001 Do not catch blind exception: `Exception` + providers/celery/src/airflow/providers/celery/executors/celery_executor_utils.py:283:13: BLE001 Do not catch blind exception: `Exception`
zulip/zulip (+1 -0 violations, +0 -0 fixes)
ruff check --no-cache --exit-zero --ignore RUF9 --no-fix --output-format concise --preview --select ALL
+ zerver/webhooks/slack/view.py:225:29: BLE001 Do not catch blind exception: `Exception`
Changes by rule (1 rules affected)
| code | total | + violation | - violation | + fix | - fix |
|---|---|---|---|---|---|
| BLE001 | 3 | 3 | 0 | 0 | 0 |
5620d2f to
e433fe7
Compare
lake8-blind-except] Change BLE001 to correctly parse exception tuplesflake8-blind-except] Change BLE001 to correctly parse exception tuples
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR enhances the
BLE001rule 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 likeexcept (Exception, ValueError):.Test Plan
It fails the following (whereas the main branch does not):