Skip to content

except-pass (ODOO004)

Preview (since 0.16.2.1) · Related issues · View source

Derived from the odoo linter.

This rule is unstable and in preview. The --preview flag is required for use.

What it does

Checks for except blocks whose entire body is a bare pass.

Why is this bad?

Silently swallowing an exception without at least logging it makes bugs hard to diagnose. If the exception is genuinely expected and ignorable, prefer contextlib.suppress, which documents that intent; otherwise, log the exception.

Example

try:
    do_something()
except Exception:
    pass

Use instead:

try:
    do_something()
except Exception:
    _logger.exception("do_something failed")