Skip to content

Instantly share code, notes, and snippets.

@stupoid
Created December 23, 2020 02:18
Show Gist options
  • Save stupoid/7015ef3b5b7d3829d775e83a8be7baac to your computer and use it in GitHub Desktop.
Save stupoid/7015ef3b5b7d3829d775e83a8be7baac to your computer and use it in GitHub Desktop.
General shell scripts for python dev
#!/bin/sh
lint() {
TARGET_FOLDERS=$@
if [ -z "$TARGET_FOLDERS" ]; then
TARGET_FOLDERS="app tests"
fi
echo "linting folders $TARGET_FOLDERS..."
echo "running autoflake"
autoflake --recursive --in-place --remove-unused-variables $TARGET_FOLDERS
echo "running isort"
isort $TARGET_FOLDERS
echo "running black"
black --quiet $TARGET_FOLDERS
echo "linting done"
}
watch_tests() {
TARGET_FOLDERS=$@
if [ -z "$TARGET_FOLDERS" ]; then
TARGET_FOLDERS="*/*.py"
fi
echo "watching files $TARGET_FOLDERS"
ls $TARGET_FOLDERS | entr pytest --tb=short
}
case $1 in
lint)
shift
lint $@
break
;;
watch-tests)
shift
watch_tests $@
break
;;
*)
echo "Sorry, I don't understand"
;;
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment