What does '# noqa' mean in Python comments?

前端 未结 3 639
执笔经年
执笔经年 2020-12-02 10: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         


        
3条回答
  •  误落风尘
    2020-12-02 11:29

    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.

提交回复
热议问题