]> git.scottworley.com Git - nix-env-apps/blobdiff - test.sh
mypy, pylint, autopep8, & pre-commit hook to run them
[nix-env-apps] / test.sh
diff --git a/test.sh b/test.sh
new file mode 100755 (executable)
index 0000000..998b58e
--- /dev/null
+++ b/test.sh
@@ -0,0 +1,22 @@
+#!/bin/sh
+
+set -e
+
+find . -name build -prune -o -name dist -prune -o -name '*.py' -print0 |
+  xargs -0 mypy --strict --ignore-missing-imports --no-warn-unused-ignores
+
+if [ "$1" = lint ];then
+
+  find . -name '*.py' -print0 | xargs -0 pylint --reports=n --persistent=n --ignore-imports=y -d fixme,invalid-name,missing-docstring,subprocess-run-check,too-few-public-methods
+
+  formatting_needs_fixing=$(
+    find . -name '*.py' -print0 |
+      xargs -0 -n1 autopep8 --diff -aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+  )
+  if [ -n "$formatting_needs_fixing" ];then
+    echo "Formatting needs fixing:"
+    echo "$formatting_needs_fixing"
+    exit 1
+  fi
+
+fi