Quantcast
Viewing latest article 37
Browse Latest Browse All 43

Answer by Chase Seibert for How do I get Pyflakes to ignore a statement?

Here is a monkey patch for pyflakes that adds a # bypass_pyflakes comment option.

bypass_pyflakes.py

#!/usr/bin/env pythonfrom pyflakes.scripts import pyflakesfrom pyflakes.checker import Checkerdef 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 bypassChecker.report = report_with_bypasspyflakes.main()

If you save this as bypass_pyflakes.py, then you can invoke it as python bypass_pyflakes.py myfile.py.

http://chase-seibert.github.com/blog/2013/01/11/bypass_pyflakes.html


Viewing latest article 37
Browse Latest Browse All 43

Trending Articles