What does '# noqa' mean in Python comments?
Solution 1:
Adding # noqa
to a line indicates that the linter (a program that automatically checks code quality) should not check this line. Any warnings that code may have generated will be ignored.
That line may have something that "looks bad" to the linter, but the developer understands and intends it to be there for some reason.
For more information, see the Flake8 documentation for Selecting and Ignoring Violations.
Solution 2:
noqa = NO-QA (NO Quality Assurance)
It's generally referred in Python Programming to ignore the PEP8 warnings.
In simple words, lines having #noqa at the end will be ignored by the linter programs and they won't raise any warnings.
Solution 3:
You know what? Even Guido van Rossum (the creator of Python) asked this question before :D
A bit Etymology of # noqa
:
It used to be "nopep8" but when Flake8 and Pep8 wanted a common qualifier @florentx suggested "NoQA" as in "No Quality Assurance" (iirc) and it stuck.
Some basic usages of # noqa
(with flake8):
-
# flake8: noqa
: files that contain this line are skipped -
lines that contain a
# noqa
comment at the end: will not issue warnings -
# noqa: <error>
, e.g.,# noqa: E234
at the end: ignore specific errors on a line- multiple error codes can be given, separated by comma
- the colon before the list of codes is required