What does '# noqa' mean in Python comments

2019-02-01 17:38发布

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?

2条回答
Fickle 薄情
2楼-- · 2019-02-01 17:46

noqa = NO-QA (NO Quality Assurance)

Its 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 wont raise any warnings.

查看更多
Animai°情兽
3楼-- · 2019-02-01 17:47

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.

查看更多
登录 后发表回答