Fix Python – What does ‘# noqa’ mean in Python comments?

Question

Asked By – Ishpreet

While searching through a Python project, I found a few lines commented with # noqa.

import sys
sys.path.append(r'C:\dev')
import some_module   # noqa

What does noqa mean in Python? Is it specific to Python only?

Now we will see solution for issue: What does ‘# noqa’ mean in Python comments?


Answer

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.

This question is answered By – jimf

This answer is collected from stackoverflow and reviewed by FixPython community admins, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0