CI: Add mypy check

Signed-off-by: Stefan Hansson <newbyte@postmarketos.org>
Part-of: <https://gitlab.postmarketos.org/postmarketOS/pmaports/-/merge_requests/7960>
This commit is contained in:
Stefan Hansson 2026-02-08 17:48:57 +01:00 committed by The Friendly Meow (merge) Bot
parent 38434fbed9
commit cfff222fb2
No known key found for this signature in database
3 changed files with 30 additions and 0 deletions

16
.ci/mypy.sh Executable file
View file

@ -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 .

2
.ci/pyproject.toml Normal file
View file

@ -0,0 +1,2 @@
[tool.mypy]
disable_error_code = ["import-not-found"]

View file

@ -62,6 +62,18 @@ ruff:
- .ci/lib/gitlab_prepare_ci.sh - .ci/lib/gitlab_prepare_ci.sh
- .ci/ruff.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 and various grep checks
shellcheck-grep: shellcheck-grep:
stage: lint stage: lint