mirror of
https://github.com/vale981/poetry2nix
synced 2025-03-05 09:11:39 -05:00
Add tooling to detect Python2 syntax errors
This commit is contained in:
parent
8078110a7f
commit
b8d3545eba
2 changed files with 17 additions and 0 deletions
|
@ -14,6 +14,7 @@ pkgs.mkShell {
|
||||||
|
|
||||||
buildInputs = [
|
buildInputs = [
|
||||||
tools.env
|
tools.env
|
||||||
|
tools.py2-astparse
|
||||||
tools.flamegraph
|
tools.flamegraph
|
||||||
tools.release
|
tools.release
|
||||||
pkgs.nixpkgs-fmt
|
pkgs.nixpkgs-fmt
|
||||||
|
|
|
@ -77,4 +77,20 @@ in
|
||||||
projectDir = ./.;
|
projectDir = ./.;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
py2-astparse = pkgs.writeScriptBin "py2-astparse" ''
|
||||||
|
#!${pkgs.python2.interpreter}
|
||||||
|
# Used as a smoke test for Python2 compatibility in Python files
|
||||||
|
import sys
|
||||||
|
import ast
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
with open(sys.argv[1]) as f:
|
||||||
|
try:
|
||||||
|
ast.parse(f.read())
|
||||||
|
except Exception as e:
|
||||||
|
sys.stderr.write("Error parsing '{}':\n".format(sys.argv[1]))
|
||||||
|
sys.stderr.flush()
|
||||||
|
raise
|
||||||
|
'';
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue