aboutsummaryrefslogtreecommitdiff
path: root/test/lint
diff options
context:
space:
mode:
authorKiminuo <kiminuo@protonmail.com>2020-02-25 20:05:48 +0100
committerKiminuo <kiminuo@protonmail.com>2020-06-02 08:03:02 +0200
commitbd7e530f010d43816bb05d6f1590d1cd36cdaa2c (patch)
treeb6d140aa5fe2cf2b851d2b6e140e26eaa44e996a /test/lint
parent9bc7751cadbd038faf8ac1d62cda23fcf00d4cc2 (diff)
downloadbitcoin-bd7e530f010d43816bb05d6f1590d1cd36cdaa2c.tar.xz
This PR adds initial support for type hints checking in python scripts.
Support for type hints was introduced in Python 3.5. Type hints make it easier to read and review code in my opinion. Also an IDE may discover a potential bug sooner. Yet, as PEP 484 says: "It should also be emphasized that Python will remain a dynamically typed language, and the authors have no desire to ever make type hints mandatory, even by convention." Mypy is used in lint-python.sh to do the type checking. The package is standard so there is little chance that it will be abandoned. Mypy checks that type hints in source code are correct when they are not, it fails with an error. Useful resources: * https://docs.python.org/3.5/library/typing.html * https://www.python.org/dev/peps/pep-0484/
Diffstat (limited to 'test/lint')
-rwxr-xr-xtest/lint/lint-python.sh3
1 files changed, 3 insertions, 0 deletions
diff --git a/test/lint/lint-python.sh b/test/lint/lint-python.sh
index 86ac5a930f..b9aa6c799b 100755
--- a/test/lint/lint-python.sh
+++ b/test/lint/lint-python.sh
@@ -7,6 +7,7 @@
# Check for specified flake8 warnings in python files.
export LC_ALL=C
+export MYPY_CACHE_DIR="${BASE_ROOT_DIR}/test/.mypy_cache"
enabled=(
E101 # indentation contains mixed spaces and tabs
@@ -96,3 +97,5 @@ PYTHONWARNINGS="ignore" flake8 --ignore=B,C,E,F,I,N,W --select=$(IFS=","; echo "
echo "$@"
fi
)
+
+mypy --ignore-missing-imports $(git ls-files "test/functional/*.py") \ No newline at end of file