Skip to content

bare-raise-outside-handler

Pythoncorrectnessno fixdefault: warnpython/ruff

Reports a raise with no exception in code that no except clause of its function contains.

A bare raise re-raises the exception being handled. With no except around it, it fails with RuntimeError: No active exception to reraise, unless the function is only ever called from a handler, which nothing in the file shows.

To fix, raise a named exception, or move the raise into the except clause.

Reported
...
raise NotImplementedError
raise
python:
lint:
rules:
bare-raise-outside-handler: warn # off, warn (default), error

Enabled by the presets: python/ruff.

Suppress one line with sudsy-disable-next-line bare-raise-outside-handler in a comment of the file’s language.

The same check in other tools; Sudsy reports what each upstream rule reports.

Tool Rule Match
ruff PLE0704 full