Skip to content

Commit 958bf40

Browse files
practicalswiftken2812221
authored andcommitted
add lint tool to check python3 shebang
1 parent 5df84de commit 958bf40

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/bin/bash
2+
# Shebang must use python3 (not python or python2)
3+
EXIT_CODE=0
4+
for PYTHON_FILE in $(git ls-files -- "*.py"); do
5+
if [[ $(head -c 2 "${PYTHON_FILE}") == "#!" &&
6+
$(head -n 1 "${PYTHON_FILE}") != "#!/usr/bin/env python3" ]]; then
7+
echo "Missing shebang \"#!/usr/bin/env python3\" in ${PYTHON_FILE} (do not use python or python2)"
8+
EXIT_CODE=1
9+
fi
10+
done
11+
exit ${EXIT_CODE}

0 commit comments

Comments
 (0)