Pyflakes is a popular linter for python, even if it isn’t being maintained anymore. One long standing request is to allow ignoring of specific warnings with comments, like many other linters allow.

For example, it’s common in python config files to use import *. But you definitely don’t want to allow that in most places.

form settings.base import *
MY_OVERIDE = 'foobar'  # over-ride this setting from base

This results in the warning settings/local.py:1: 'from settings.base import *' used; unable to detect undefined names.

It would be nice to be able to do the following.

form settings.base import *  # bypass_pyflakes
MY_OVERIDE = 'foobar'  # over-ride this setting from base

Here is a python script that monkey patches pyflakes to add this functionality.

#!/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()

If you save this as pyflakes-bypass.py, instead of running the pyflakes <path> command directly, you would now run pyflakes-bypass.py <path>.