From 6201f6020dad25af6ff8b210dab0c5a50ad15d6d Mon Sep 17 00:00:00 2001 From: "Erlend E. Aasland" Date: Thu, 11 Jul 2024 12:48:22 +0200 Subject: [PATCH 1/4] 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 From 88d176580348a887a1a90048b5a631960ca3d29b Mon Sep 17 00:00:00 2001 From: "Erlend E. Aasland" Date: Thu, 11 Jul 2024 13:21:53 +0200 Subject: [PATCH 2/4] Also install project --- .github/workflows/pythonpackage.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pythonpackage.yml b/.github/workflows/pythonpackage.yml index 76cc9e8d..2d3ad968 100644 --- a/.github/workflows/pythonpackage.yml +++ b/.github/workflows/pythonpackage.yml @@ -66,5 +66,5 @@ jobs: cache-dependency-path: | 'pyproject.toml' 'requirements-dev.txt' - - run: pip install -r requirements-dev.txt + - run: pip install -r requirements-dev.txt -e . - run: mypy --config-file pyproject.toml . From 4efb9d9992271f34f5b2cdc4ca430f84940f4d04 Mon Sep 17 00:00:00 2001 From: "Erlend E. Aasland" Date: Thu, 11 Jul 2024 13:23:24 +0200 Subject: [PATCH 3/4] Don't have to run mypy on 3.8 in order to enforce 3.8 annotations --- .github/workflows/pythonpackage.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pythonpackage.yml b/.github/workflows/pythonpackage.yml index 2d3ad968..25fa9dc3 100644 --- a/.github/workflows/pythonpackage.yml +++ b/.github/workflows/pythonpackage.yml @@ -61,7 +61,7 @@ jobs: - uses: actions/checkout@v4 - uses: actions/setup-python@v5 with: - python-version: "3.8" + python-version: 3.12 cache: pip cache-dependency-path: | 'pyproject.toml' From 5b8d3e99ba55a1e76e32b4551128900aff59893f Mon Sep 17 00:00:00 2001 From: "Erlend E. Aasland" Date: Tue, 15 Oct 2024 23:44:11 +0200 Subject: [PATCH 4/4] Add newline at EOF --- requirements-dev.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements-dev.txt b/requirements-dev.txt index 0dd90105..23f3a7aa 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -1,3 +1,3 @@ mypy~=1.10 pytest~=8.3 -pytest-cov~=5.0 \ No newline at end of file +pytest-cov~=5.0