Skip to content

unused-noqa (KNQ003)

unused noqa

Fix is available.

What it does

Flags codes in a # noqa: CODE comment that suppress nothing: no enabled rule reports a violation with that code on that line. Only codes konform reports are judged, so # noqa: E501 for another tool and a bare # noqa are left alone, and so are codes of rules that are turned off. Opt-in: enable it with extend-select = ["KNQ003"] in [tool.konform.lint] (or --extend-select KNQ003).

Why is this bad?

A stale suppression hides nothing today but silently swallows the next real violation on that line. Removing it keeps every remaining # noqa meaningful.

Example

import os  # noqa: KIS001
from os.path import join  # noqa: KIS001, KIS002

Use instead:

import os
from os.path import join  # noqa: KIS001

How codes are matched

A code counts as used when a violation on the same line starts with it, directly or through noqa-aliases, the same way the suppression itself works. A violation filtered out by per-file-ignores does not use a code. KNQ codes are never flagged.

Suppressing and fixing

This rule cannot be suppressed with # noqa; turn it off with ignore or per-file-ignores. The fix is safe: it removes the unused codes, or the whole directive (and its reason) when no code is left.

Options

Configured in [tool.konform.lint.unused-noqa].

Option Type Default Description
level "warning" \| "error" "error" Severity of violations.

Suppression

x = 1  # noqa: KNQ003
x = 1  # noqa: KNQ  (every KNQ* rule)