Skip to content

invalid-rule-code (RUF102)

Added in 0.15.0 · Related issues · View source

Fix is always available.

What it does

Checks for noqa codes that are invalid.

Why is this bad?

Invalid rule codes serve no purpose and may indicate outdated code suppressions.

Example

import os  # noqa: XYZ999

Use instead:

import os

Or if there are still valid codes needed:

import os  # noqa: E402

Options

This rule will flag rule codes that are unknown to Ruff, even if they are valid for other tools. You can tell Ruff to ignore such codes by configuring the list of known "external" rule codes with the following option: