Last active
December 22, 2015 14:09
-
-
Save cpelley/6484171 to your computer and use it in GitHub Desktop.
Pyflakes monkey-patch to give appropriately formatted syntax error for vim
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
#!/usr/bin/env python | |
import sys | |
import pyflakes.reporter as reporter | |
from pyflakes.scripts.pyflakes import main | |
# Monkey patch syntax error method for suitability with vim | |
def vimhappy_syntaxError(self, filename, msg, lineno, offset, text): | |
line = text.splitlines()[-1] | |
if offset is not None: | |
offset = offset - (len(text) - len(line)) | |
self._stderr.write(reporter.u('%s:%d:%d: %s\n') % (filename, lineno, | |
offset+1, msg)) | |
reporter.Reporter.syntaxError = vimhappy_syntaxError | |
main(sys.argv[1:]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment