Skip to content

redundant-tuple-in-exception-handler

Pythonstyleno fixdefault: warnpython/ruff

Reports an except clause that names a tuple of one exception, except (E,):.

The parentheses and comma make a tuple for no reason, and a reader looks for the other exceptions that are missing.

To fix, write except E:.

Reported
...
zip(a, b, strict=True)
try:
pass
except (ValueError,):
pass
except (ValueError, TypeError):
pass
python:
lint:
rules:
redundant-tuple-in-exception-handler: warn # off, warn (default), error

Enabled by the presets: python/ruff.

Suppress one line with sudsy-disable-next-line redundant-tuple-in-exception-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 B013 full