-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
BLE001: conditional handling of errors not detected #11289
Comments
|
## Summary Historically, we only ignored `flake8-blind-except` if you re-raised or logged the exception as a _direct_ child statement; but it could be nested somewhere. This was just a known limitation at the time of adding the previous logic. Closes #11289.
We were recently investigating the 0.4.4 upgrade and found that snippets like this:
would no longer raise |
A more complex visitor would need to be implemented like in flake8-trio. |
Thanks @rahulssheth. My overall feeling was that if you're re-raising even within a branch, then the use of the catch-all exception was probably intentional, and so likely to be a false positive. Are you seeing real cases where you do want it to be flagged, despite a re-raise? |
@charliermarsh good point! In most scenarios, if there's some sort of explicit handling with a re-raise, even if there isn't always a re-raise, it likely isn't an problem. I mostly flagged this issue because I think there's a case to be made that false positives with an ignore should be preferred to false negatives here, but I haven't seen any real cases that merit a change of approach. Appreciate the quick feedback! |
keywords: BLE001, log, exception
The following code snippet does not trigger the BLE001 rule:
but this one does:
This is because ruff doesn't seem to consider the case the both branches of an
if
handle the error.The reason we run into this is because sometimes we use code like the following:
The text was updated successfully, but these errors were encountered: