这是pyflakes的猴子补丁,添加了# bypass_pyflakes
注释选项。
passive_pyflakes.py
#!/usr/bin/env python
from pyflakes.scripts import pyflakes
from pyflakes.checker import Checker
def report_with_bypass(self, messageClass, *args, **kwargs):
text_lineno = args[0] - 1
with open(self.filename, 'r') as code:
if code.readlines()[text_lineno].find('bypass_pyflakes') >= 0:
return
self.messages.append(messageClass(self.filename, *args, **kwargs))
# monkey patch checker to support bypass
Checker.report = report_with_bypass
pyflakes.main()
如果将其另存为bypass_pyflakes.py
,则可以将其调用为python bypass_pyflakes.py myfile.py
。
http://chase-seibert.github.com/blog/2013/01/11/bypass_pyflakes.html