Raises plain Exception
This is how the comment reads inline, under the flagged line.
Why it matters
A generic exception forces callers into except Exception, which also catches real bugs.
What to do
Raise a specific built-in (ValueError, LookupError) or your own subclass.
Examples
raise Exception("bad input")raise ValueError("member id must be a UUID")What it catches
It reads a pattern on each line, aware of strings and comments. Languages: Python. Scope: All files. These cases are the rule's own tests: the first set must be flagged and the second must not.
Flagged
raise Exception("bad")
Left alone
raise ValueError("bad")
Research
Raising bare `Exception` in Python. Callers cannot catch this failure without catching every failure.
- Ruff rules
- owner's notes
Turn it off or change it
In a config file for the CLI, or in the API's rules field:
{
"rules": {
"disable": [
"raise-bare-exception"
],
"severity": {
"raise-bare-exception": "medium"
}
}
}
Exception. Callers can't catch it without catching everything.