Skip to content

Instantly share code, notes, and snippets.

@cpelley
Created November 14, 2016 12:17
Show Gist options
  • Save cpelley/504c4919332ea13cc39a7f1acac4a2d7 to your computer and use it in GitHub Desktop.
Save cpelley/504c4919332ea13cc39a7f1acac4a2d7 to your computer and use it in GitHub Desktop.
pyflakes noqa monkeypatch
# Monkey-ptch pyflakes to respect lines with flake8 methods of ignoring
# lines and files.
def _report_with_ignore(self, messageClass, *args, **kwargs):
with open(self.filename, 'r') as code:
cont = code.readlines()
lineno = args[0].lineno
if '# noqa' in cont[lineno-1]:
return
elif '# flake8: ' + 'noqa' in ''.join(cont):
return
self.messages.append(messageClass(self.filename, *args, **kwargs))
pyflakes.checker.Checker.report = _report_with_ignore
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment