From cfff222fb2e64dd2733516b236850691155f3a11 Mon Sep 17 00:00:00 2001 From: Stefan Hansson Date: Sun, 8 Feb 2026 17:48:57 +0100 Subject: [PATCH] CI: Add mypy check Signed-off-by: Stefan Hansson Part-of: --- .ci/mypy.sh | 16 ++++++++++++++++ .ci/pyproject.toml | 2 ++ .gitlab-ci.yml | 12 ++++++++++++ 3 files changed, 30 insertions(+) create mode 100755 .ci/mypy.sh create mode 100644 .ci/pyproject.toml diff --git a/.ci/mypy.sh b/.ci/mypy.sh new file mode 100755 index 000000000..ab55a907e --- /dev/null +++ b/.ci/mypy.sh @@ -0,0 +1,16 @@ +#!/bin/sh -e +# Description: static type checking for python scripts +# https://postmarketos.org/pmb-ci + +if [ "$(id -u)" = 0 ]; then + set -x + apk -q add py3-argcomplete py3-pip py3-pytest + exec su "${TESTUSER:-build}" -c "sh -e $0" +fi + +set -x + +pip install --break-system-packages --no-warn-script-location mypy +# Need to change directory for pyproject.toml to be picked up. +cd .ci +python -m mypy . diff --git a/.ci/pyproject.toml b/.ci/pyproject.toml new file mode 100644 index 000000000..4f2ddc945 --- /dev/null +++ b/.ci/pyproject.toml @@ -0,0 +1,2 @@ +[tool.mypy] +disable_error_code = ["import-not-found"] diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index da6c40fc7..299fb0c74 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -62,6 +62,18 @@ ruff: - .ci/lib/gitlab_prepare_ci.sh - .ci/ruff.sh +# testcases typechecking +mypy: + stage: lint + rules: + - if: *mr_rule + changes: + - .ci/**/* + - .gitlab-ci.yml + script: + - .ci/lib/gitlab_prepare_ci.sh + - .ci/mypy.sh + # shellcheck and various grep checks shellcheck-grep: stage: lint