An except clause for Exception or BaseException does nothing but pass

tx0/python:silent-exception-handlerrecommendedwarningsmell

What it finds

except Exception: pass swallows every error, including the ones nobody expected, such as a misspelled name or a broken invariant, and the program goes on in a state that no one checked. Handling the specific exceptions that may happen, or at least logging what was caught, keeps errors visible. Reported are handlers for Exception, BaseException and bare except: whose body is only pass or ....

From the rule's source, silent_exception_handler.rs.

Example from the rule's tests
def load(path, log):    try:        return open(path).read()    except Exception:tx0 reports: this handler swallows every error without a trace        pass    try:        return open(path).read()    except OSError:        pass    try:        return open(path).read()    except Exception as error:        log(error)
Highlighted lines are the ones tx0 reports, with its message under each; the other lines are left alone.

Turn it on, off or suppress it

The rule runs from the recommended tier up. To turn it on in a lower tier, give it a level in tx0.toml:

tx0.toml
[rules]
"tx0/python:silent-exception-handler" = "warning"

To keep one finding, suppress it with a reason. tx0 suppress ID --reason "..." writes the comment on the line before the code:

# tx0: ignore[tx0/python:silent-exception-handler] reason="..."

tx0 explain tx0/python:silent-exception-handler shows the same in the terminal. Found a false positive? Report it.