Flake8 Noqa Comment Validation

1.5.0 · active · verified Sat Apr 11

flake8-noqa is a plugin for Flake8 that validates `# noqa` comments in Python code. It ensures that these comments are correctly formatted, are not redundant (i.e., they suppress an actual reported error), and that any specified error codes in `# noqa:` comments correspond to violations found on that line. The current version is 1.5.0, and it's released as needed in conjunction with Flake8 updates.

Warnings

Install

Quickstart

To use flake8-noqa, simply install it alongside Flake8. The plugin automatically integrates. After creating a Python file (e.g., `example.py`) with some code, including a correctly formatted `# noqa: F841` comment and an intentionally malformed one (`# noqa F842`), run `flake8` from your terminal. The plugin will report issues with the malformed `# noqa` comment and other linting errors.

import os

def unused_function(): # noqa: F841
    pass

def another_unused_function(): # noqa F842
    # This noqa is intentionally malformed to trigger flake8-noqa
    pass

def missing_docstring():
    # This will trigger a D103 error (if pydocstyle is enabled)
    pass

view raw JSON →