-
Notifications
You must be signed in to change notification settings - Fork 2k
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
keywords: BLE001, log, exception
The following code snippet does not trigger the BLE001 rule:
from logging import exception
try:
pass
except Exception:
exception("An error occurred")but this one does:
from logging import exception
try:
pass
except Exception:
if True:
exception("An error occurred")
else:
exception("An error occurred")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:
from logging import exception
try:
pass
except Exception as ex:
error_data = gather_diagnostic_data(...)
if isinstance(ex, SomespecificError):
exception("A specific error occurred", extra=error_data)
else:
exception("A generic error occurred", extra=error_data)Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working