pylint-disable-comment (ODOO047)
Preview (since 0.16.2.3) · Related issues · View source
Derived from the odoo linter.
Fix is sometimes available.
This rule is unstable and in preview. The --preview flag is required for use.
What it does
Checks for # pylint: disable=... comments that suppress checks Ruff now
covers, so they can be migrated to Ruff's # noqa: ... format.
A message is considered covered when it matches a Ruff rule name (most
pylint-odoo checks were ported under their original names, and many pylint
checks exist in Ruff under the same name, e.g. too-many-branches), a
pylint-odoo message code (e.g. E8102), or a known rename (e.g. pylint's
too-complex is Ruff's complex-structure / C901).
Why is this bad?
After migrating from pylint / pylint-odoo to Ruff, # pylint: disable
comments have no effect: Ruff only honors # noqa directives, so the
previously silenced diagnostics are reported again despite the suppression
comment.
Example
Use instead:
Fix safety
An inline (trailing) disable pragma is rewritten in place and the fix is
safe: an inline pylint disable and a noqa both suppress findings on that
single line, so the rewrite preserves behavior.
A standalone # pylint: disable comment applies to the rest of the enclosing
block, which no single noqa can express. Its fix deletes the pragma and puts
a # noqa on each line inside that block where one of the named rules
currently fires; a pragma that silences nothing is simply removed. That fix is
marked unsafe, because code added to the block later is no longer covered by
the suppression, and it is only offered when every rule the pragma names is
enabled in the run — a rule that isn't selected can't be observed firing, so
dropping its pragma could unsuppress it later.
Messages without a Ruff equivalent are kept in a # pylint: disable comment
next to the inserted noqa.