From 8f4a32070264cbe1cbb55ddcad25120505d48dce Mon Sep 17 00:00:00 2001 From: Andras Schmelczer Date: Sun, 19 Jun 2022 17:03:40 +0200 Subject: [PATCH] Fix scripts when there are only notebooks --- scripts/check-python.sh | 8 ++++++-- scripts/format-python.sh | 8 ++++++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/scripts/check-python.sh b/scripts/check-python.sh index 4c239d9..d5bf925 100755 --- a/scripts/check-python.sh +++ b/scripts/check-python.sh @@ -13,9 +13,13 @@ python3 -m autoflake --expand-star-imports --remove-all-unused-imports --ignore- python3 -m isort --profile black --skip .env . --check python3 -m black . --exclude .env --check -yes | python3 -m mypy . --install-types > /dev/null || true -python3 -m mypy --namespace-packages --ignore-missing-imports --install-types --non-interactive --disallow-untyped-defs --disallow-incomplete-defs --follow-imports=silent --exclude=external/ --exclude=/build/ --pretty . +if ls *.py 1> /dev/null 2>&1; then + yes | python3 -m mypy . --install-types > /dev/null || true + python3 -m mypy --namespace-packages --ignore-missing-imports --install-types --non-interactive --disallow-untyped-defs --disallow-incomplete-defs --follow-imports=silent --exclude=external/ --exclude=/build/ --pretty . +fi python3 -m flake8 . --count --show-source --statistics --exclude=__init__.py,.env,external --ignore=E501,E722,E402,W503,E203 cd - + +echo "Finished checking" diff --git a/scripts/format-python.sh b/scripts/format-python.sh index e4e9a8d..737a2b9 100755 --- a/scripts/format-python.sh +++ b/scripts/format-python.sh @@ -18,10 +18,14 @@ python3 -m isort --profile black --skip .env . echo Running black python3 -m black . --exclude .env -echo Running mypy -python3 -m mypy --namespace-packages --ignore-missing-imports --install-types --non-interactive --disallow-untyped-defs --disallow-incomplete-defs --pretty --follow-imports=silent --exclude=external/ --exclude=/build/ . +if ls *.py 1> /dev/null 2>&1; then + echo Running mypy + python3 -m mypy --namespace-packages --ignore-missing-imports --install-types --non-interactive --disallow-untyped-defs --disallow-incomplete-defs --pretty --follow-imports=silent --exclude=external/ --exclude=/build/ . +fi echo Running Flake8 python3 -m flake8 . --count --show-source --statistics --exclude=__init__.py,.env,external --ignore=E501,E722,E402,W503,E203 cd - + +echo "Finished formatting"