Skip to content

Instantly share code, notes, and snippets.

@markuskreitzer
Created April 10, 2025 18:08
Show Gist options
  • Select an option

  • Save markuskreitzer/5f2a855161a0b1fa72cc3d79c055b85f to your computer and use it in GitHub Desktop.

Select an option

Save markuskreitzer/5f2a855161a0b1fa72cc3d79c055b85f to your computer and use it in GitHub Desktop.
Python Pre-Commit Hooks
#!/bin/sh
echo "Running Checks..."
poetry run flake8 src tests \
&& poetry run black src tests \
&& poetry run isort src tests \
&& poetry run pytest \
&& poetry run bandit src \
&& poetry run pip-audit . \
&& poetry run mypy src tests
# && poetry run safety scan
# Store the exit code
RESULT=$?
if [ $RESULT -ne 0 ]; then
echo "We found code style issues. Please fix them before committing."
exit 1
fi
echo "All checks passed. Proceeding with commit."
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment