Registry / testing / flake8-noqa

flake8-noqa

JSON →
library1.5.0pypypiunverified

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.

pip install flake8-noqa
INSTALL
IMPORT
SIG · FLAKE8-NOQA
F
flake8-noqa
testingpythonv1.5.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

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
Debug
Known issues
gotchaIncorrect formatting of `# noqa` comments can lead to them being ignored entirely or interpreted as a blanket `# noqa` (ignoring all errors on the line) even if specific codes were intended. Common mistakes include `# noqa F841`, `# noqa : F841`, or extra spaces.
fix
Ensure `# noqa` comments are strictly formatted as `# noqa: CODE` (e.g., `# noqa: F841`) to apply to specific errors, or simply `# noqa` to ignore all errors on a line. The plugin helps catch these issues.
affects: All versions
gotchaErrors reported by `flake8-noqa` (e.g., about malformed or unnecessary `# noqa` comments) cannot be suppressed using another `# noqa` comment. Trying to do so will not work.
fix
To ignore errors reported by `flake8-noqa` itself, you must use Flake8's standard configuration options such as `ignore`, `extend-ignore`, or `per-file-ignores` in your `setup.cfg`, `tox.ini`, or `.flake8` file.
affects: All versions
gotchaSome other Flake8 plugins might perform their own processing of `# noqa` comments and stop reporting violations to Flake8. This can prevent `flake8-noqa` from accurately detecting whether a `# noqa` comment is necessary or correctly matches an existing violation.
fix
The recommended approach is to configure such problematic plugins to *not* respect `# noqa` comments, allowing Flake8 (and by extension `flake8-noqa`) to handle all `# noqa` processing uniformly. If the plugin lacks such an option, consider reporting an issue to its maintainers.
affects: All versions
gotchaUsing file-level `# flake8: noqa: CODE` (e.g., `# flake8: noqa: E712`) is often misunderstood. Flake8 will ignore *all* errors in the file, not just the specified ones, leading to potential overlooked issues.
fix
To ignore specific errors across a file, use Flake8's `per-file-ignores` configuration. To ignore all errors in a file, use `# flake8: noqa` without specifying any codes, or preferably, use Flake8's `--exclude` option in your configuration.
affects: All versions
Errors
Common errors & fixes
flake8-noqa comment ignored
Your `# noqa` comment is incorrectly formatted, such as `# noqa F841`, `# noqa : F841`, or contains extra spaces, causing Flake8 or `flake8-noqa` to ignore it or interpret it as a blanket `# noqa` for all errors on the line.
fix
Ensure your `# noqa` comments are strictly formatted with a colon and no extra spaces when specifying codes, e.g., `# noqa: F841` to ignore specific errors, or simply `# noqa` to ignore all errors on a line.
flake8-noqa NQAxxx cannot be suppressed by # noqa
Errors reported by `flake8-noqa` itself (e.g., about malformed or unnecessary `# noqa` comments, identified by codes like `NQA001`, `NQA101`, etc.) cannot be suppressed using another `# noqa` comment on the same line.
fix
To ignore errors reported by `flake8-noqa`, you must use Flake8's standard configuration options such as `ignore`, `extend-ignore`, or `per-file-ignores` in your `setup.cfg`, `tox.ini`, or `.flake8` file.
# flake8: noqa: E712 ignores all errors
When you place a file-level comment like `# flake8: noqa: E712` at the top of a file, Flake8 will ignore *all* errors in that file, not just the specific error code(s) you've listed, which can lead to overlooked issues.
fix
To ignore specific errors across an entire file, use Flake8's `per-file-ignores` configuration option in your `setup.cfg` or `.flake8` file, for example: `per-file-ignores = my_file.py:E712,F401`.
noqa does not suppress warning
A `# noqa` comment might not suppress a warning if there's an issue with its formatting, if another Flake8 plugin is processing `noqa` comments independently and stopping violation reports, or if you are using `pyflakes` directly which may not support `noqa` comments.
fix
First, verify the `# noqa` comment's formatting is correct (e.g., `# noqa: E501` or `# noqa`). If the problem persists, check for other Flake8 plugins that might be interfering and try to configure them not to respect `# noqa` comments, allowing Flake8 and `flake8-noqa` to handle suppression. Ensure you are running `flake8` directly.
Upgrade
Version history
1.5.0latest on PyPI · released Feb 7, 2026
Audit
Dependencies
flake8requiredThis is a plugin for Flake8 and requires Flake8 to function.
Agent activity
21 hits · last 30 days
node
16
Meta
2
Resources
flake8-noqa — pip install flake8-noqa · libregistry