Skip to content

Commit

Permalink
add lint tool to check python3 shebang
Browse files Browse the repository at this point in the history
  • Loading branch information
practicalswift authored and str4d committed Oct 27, 2020
1 parent eab2490 commit 5d0affe
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions contrib/devtools/lint-python-shebang.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash
# Shebang must use python3 (not python or python2)
EXIT_CODE=0
for PYTHON_FILE in $(git ls-files -- "*.py"); do
if [[ $(head -c 2 "${PYTHON_FILE}") == "#!" &&
$(head -n 1 "${PYTHON_FILE}") != "#!/usr/bin/env python3" ]]; then
echo "Missing shebang \"#!/usr/bin/env python3\" in ${PYTHON_FILE} (do not use python or python2)"
EXIT_CODE=1
fi
done
exit ${EXIT_CODE}

0 comments on commit 5d0affe

Please sign in to comment.