You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
According to the docs, blind-except (BLE001) says that except Exception is bad, which I agree with. But it looks like ruff by default doesn't actually check for blind-except at all. Is this intentional? If there are errors that ruff does not check for by default, it would make sense to me to document with those errors, that they are off by default.
This test.py file does not get flagged by ruff as being invalid.
a = 1
b = 0
try:
print(a / b)
except Exception as e:
print(e)
try:
print(a / b)
except Exception:
print("error")
try:
print(a / b)
except BaseException:
print("error2")
Ok, this is as intended. I am just surprised this is not on by default. Also, i think it makes sense to document what rules are on by default with the rules. Now it's really tedious to search through the default config and then the list of rules what is and isn't on by default. But that's a different issue.
Only a pretty small set of rules is enabled by default. See the rule documentation:
By default, Ruff enables Flake8's F rules, along with a subset of the E rules, omitting any stylistic rules that overlap with the use of a formatter, like ruff format or Black.
You can also run ruff check --show-settings and look for the linter.rules_enabled section. That shows all of the enabled rules with their names and codes.
I think some people also like to use the special ALL rule code to select all rules and then ignore the ones they don't want. If you want to enable a large number of rules, that could be easier than selecting them all.
Maybe it would be nice if we added an icon for default rules in the main rules page, though.
Summary
According to the docs, blind-except (BLE001) says that
except Exception
is bad, which I agree with. But it looks like ruff by default doesn't actually check for blind-except at all. Is this intentional? If there are errors that ruff does not check for by default, it would make sense to me to document with those errors, that they are off by default.This test.py file does not get flagged by ruff as being invalid.
While if I turn it into this:
it does get flagged as a bare except:
And running ruff with selecting BLE001 explicitely also flags it:
Version
0.3.7 and 0.11.0
The text was updated successfully, but these errors were encountered: