From df6be0e8c0b95af80f97264a2dc615b565bfc098 Mon Sep 17 00:00:00 2001 From: Kittywhiskers Van Gogh <63189531+kwvg@users.noreply.github.com> Date: Sat, 23 Nov 2024 18:25:18 +0000 Subject: [PATCH] partial bitcoin#23212: enable mypy import checking --- ci/lint/04_install.sh | 3 ++- contrib/containers/ci/Dockerfile | 8 ++++---- contrib/devtools/security-check.py | 2 +- contrib/devtools/symbol-check.py | 2 +- test/README.md | 15 +++++++++------ test/functional/combine_logs.py | 2 +- test/functional/data/__init__.py | 0 test/functional/test_runner.py | 2 +- 8 files changed, 19 insertions(+), 15 deletions(-) create mode 100644 test/functional/data/__init__.py diff --git a/ci/lint/04_install.sh b/ci/lint/04_install.sh index 63fd3fc9c4..f7aa0dcd04 100755 --- a/ci/lint/04_install.sh +++ b/ci/lint/04_install.sh @@ -13,8 +13,9 @@ update-alternatives --install /usr/bin/clang-format-diff clang-format-diff $(whi ${CI_RETRY_EXE} pip3 install codespell==2.0.0 ${CI_RETRY_EXE} pip3 install flake8==3.8.3 +${CI_RETRY_EXE} pip3 install mypy==0.910 +${CI_RETRY_EXE} pip3 install pyzmq==22.3.0 ${CI_RETRY_EXE} pip3 install vulture==2.3 -${CI_RETRY_EXE} pip3 install mypy==0.781 SHELLCHECK_VERSION=v0.8.0 curl -sL "https://github.com/koalaman/shellcheck/releases/download/${SHELLCHECK_VERSION}/shellcheck-${SHELLCHECK_VERSION}.linux.x86_64.tar.xz" | tar --xz -xf - --directory /tmp/ diff --git a/contrib/containers/ci/Dockerfile b/contrib/containers/ci/Dockerfile index 9fc318d913..29bb92fff2 100644 --- a/contrib/containers/ci/Dockerfile +++ b/contrib/containers/ci/Dockerfile @@ -77,10 +77,10 @@ RUN pip3 install \ flake8==3.8.3 \ jinja2 \ lief==0.13.2 \ - pyzmq \ - vulture==2.3 \ - mypy==0.781 \ - multiprocess + multiprocess \ + mypy==0.910 \ + pyzmq==22.3.0 \ + vulture==2.3 # dash_hash ARG DASH_HASH_VERSION=1.4.0 diff --git a/contrib/devtools/security-check.py b/contrib/devtools/security-check.py index 2844b65d77..51b685819e 100755 --- a/contrib/devtools/security-check.py +++ b/contrib/devtools/security-check.py @@ -10,7 +10,7 @@ Otherwise the exit status will be 1 and it will log which executables failed whi import sys from typing import List -import lief +import lief #type:ignore def check_ELF_RELRO(binary) -> bool: ''' diff --git a/contrib/devtools/symbol-check.py b/contrib/devtools/symbol-check.py index 41bcfc4e27..7c34f59369 100755 --- a/contrib/devtools/symbol-check.py +++ b/contrib/devtools/symbol-check.py @@ -13,7 +13,7 @@ Example usage: import sys from typing import Dict, List -import lief +import lief #type:ignore # Debian 11 (Bullseye) EOL: 2026. https://wiki.debian.org/LTS # diff --git a/test/README.md b/test/README.md index 14c6982da4..8107799c91 100644 --- a/test/README.md +++ b/test/README.md @@ -308,12 +308,15 @@ Use the `-v` option for verbose output. #### Dependencies -| Lint test | Dependency | Version [used by CI](../ci/lint/04_install.sh) | Installation -|-----------|:----------:|:-------------------------------------------:|-------------- -| [`lint-python.sh`](lint/lint-python.sh) | [flake8](https://gitlab.com/pycqa/flake8) | [3.8.3](https://github.com/bitcoin/bitcoin/pull/19348) | `pip3 install flake8==3.8.3` -| [`lint-python.sh`](lint/lint-python.sh) | [mypy](https://github.com/python/mypy) | [0.781](https://github.com/bitcoin/bitcoin/pull/19348) | `pip3 install mypy==0.781` -| [`lint-shell.sh`](lint/lint-shell.sh) | [ShellCheck](https://github.com/koalaman/shellcheck) | [0.7.2](https://github.com/bitcoin/bitcoin/pull/21749) | [details...](https://github.com/koalaman/shellcheck#installing) -| [`lint-spelling.sh`](lint/lint-spelling.sh) | [codespell](https://github.com/codespell-project/codespell) | [2.0.0](https://github.com/bitcoin/bitcoin/pull/20817) | `pip3 install codespell==2.0.0` +| Lint test | Dependency | +|-----------|:----------:| +| [`lint-python.sh`](lint/lint-python.sh) | [flake8](https://gitlab.com/pycqa/flake8) +| [`lint-python.sh`](lint/lint-python.sh) | [mypy](https://github.com/python/mypy) +| [`lint-python.sh`](lint/lint-python.sh) | [pyzmq](https://github.com/zeromq/pyzmq) +| [`lint-shell.sh`](lint/lint-shell.sh) | [ShellCheck](https://github.com/koalaman/shellcheck) +| [`lint-spelling.sh`](lint/lint-spelling.sh) | [codespell](https://github.com/codespell-project/codespell) + +In use versions and install instructions are available in the [CI setup](../ci/lint/04_install.sh). Please be aware that on Linux distributions all dependencies are usually available as packages, but could be outdated. diff --git a/test/functional/combine_logs.py b/test/functional/combine_logs.py index 2e4f2c4a5a..fcedf5ce76 100755 --- a/test/functional/combine_logs.py +++ b/test/functional/combine_logs.py @@ -188,7 +188,7 @@ def print_logs_plain(log_events, colors): def print_logs_html(log_events): """Renders the iterator of log events into html.""" try: - import jinja2 + import jinja2 #type:ignore except ImportError: print("jinja2 not found. Try `pip install jinja2`") sys.exit(1) diff --git a/test/functional/data/__init__.py b/test/functional/data/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/test/functional/test_runner.py b/test/functional/test_runner.py index 8da7df9f1e..da9714ebb0 100755 --- a/test/functional/test_runner.py +++ b/test/functional/test_runner.py @@ -40,7 +40,7 @@ except UnicodeDecodeError: CROSS = "x " CIRCLE = "o " -if os.name != 'nt' or sys.getwindowsversion() >= (10, 0, 14393): +if os.name != 'nt' or sys.getwindowsversion() >= (10, 0, 14393): #type:ignore if os.name == 'nt': import ctypes kernel32 = ctypes.windll.kernel32 # type: ignore