Created
November 25, 2014 01:20
-
-
Save rakete/2699be18d4218685c66d to your computer and use it in GitHub Desktop.
hack to make pylint work with hy-lang
This file contains 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/python2.7 | |
import ast | |
from hy.lex import LexException, PrematureEndOfInput, tokenize | |
from hy.compiler import hy_compile, HyTypeError | |
import astroid.builder | |
from _ast import PyCF_ONLY_AST | |
def parse(string): | |
try: | |
return compile(string, "<string>", 'exec', PyCF_ONLY_AST) | |
except: | |
tokens = tokenize(string) | |
return hy_compile(tokens, '__console__', root=ast.Module) | |
astroid.builder.parse = parse | |
from pylint import run_pylint | |
run_pylint() |
For anyone wondering how to make this work, looks like astroid builder now uses _parse
instead of parse
.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
To use this you need to have pylint (and astroid, which is a dependency of pylint) installed:
pip install pylint
And then you should be able to just run hylint.py as if it were pylint to check hy sources.