From 398d72cbe73ce88af12b21fcff92c205921126f9 Mon Sep 17 00:00:00 2001 From: "Erlend E. Aasland" Date: Thu, 11 Jul 2024 12:48:22 +0200 Subject: [PATCH] gh-358: Add mypy CI and config Estalish a minimal mypy config that ensures annotations are compatible with Python 3.8 (the oldest supported Python version). Add a forgiving CI job that does not affect the status of the GitHub workflow run. --- .github/workflows/pythonpackage.yml | 15 +++++++++++++++ pyproject.toml | 8 ++++++++ requirements-dev.txt | 1 + 3 files changed, 24 insertions(+) create mode 100644 requirements-dev.txt diff --git a/.github/workflows/pythonpackage.yml b/.github/workflows/pythonpackage.yml index 427ad9c7..76cc9e8d 100644 --- a/.github/workflows/pythonpackage.yml +++ b/.github/workflows/pythonpackage.yml @@ -53,3 +53,18 @@ jobs: run: python3 -m pip install -r doc/requirements.txt -e . - name: Build docs run: make -C doc html + + mypy: + continue-on-error: true + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + with: + python-version: "3.8" + cache: pip + cache-dependency-path: | + 'pyproject.toml' + 'requirements-dev.txt' + - run: pip install -r requirements-dev.txt + - run: mypy --config-file pyproject.toml . diff --git a/pyproject.toml b/pyproject.toml index a87ba589..e9c85993 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -48,3 +48,11 @@ testpaths = [ filterwarnings = [ "ignore::DeprecationWarning", ] + +[tool.mypy] +python_version = "3.8" +exclude = [ + "^examples*", + "^test*", + "^setup.py*", +] diff --git a/requirements-dev.txt b/requirements-dev.txt new file mode 100644 index 00000000..ede5a914 --- /dev/null +++ b/requirements-dev.txt @@ -0,0 +1 @@ +mypy~=1.10