Skip to content

Instantly share code, notes, and snippets.

@rakete
Created November 25, 2014 01:20
Show Gist options
  • Save rakete/2699be18d4218685c66d to your computer and use it in GitHub Desktop.
Save rakete/2699be18d4218685c66d to your computer and use it in GitHub Desktop.
hack to make pylint work with hy-lang
#!/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()
@rakete
Copy link
Author

rakete commented Nov 25, 2014

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.

@aurieh
Copy link

aurieh commented Jun 23, 2017

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