Created
November 14, 2016 12:17
-
-
Save cpelley/504c4919332ea13cc39a7f1acac4a2d7 to your computer and use it in GitHub Desktop.
pyflakes noqa monkeypatch
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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