Skip to content

Commit 353b491

Browse files
authored
Configure linting and lint the codebase, drop Python 3.9, enable tests on Windows (#186)
* Configure linting and lint the codebase * Drop support for Python 3.9 * Enable tests on Windows.
2 parents cb41d33 + 6cfcba9 commit 353b491

36 files changed

Lines changed: 3182 additions & 2303 deletions

.git-blame-ignore-revs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# 2025
2+
# adapt super() calls to Python 3
3+
97c43eb36fa04c8dde2bb5acacdb00782697ad86
4+
# clean up from Python 3 transition: class XYZ(object) -> class XYZ
5+
142d3d9226228e8fc9cac73013990b1ff41d9782
6+
# remove u'' string prefixes
7+
d41faf0bdf0ba5e899625c0f2fd2421aaad8ff1c
8+
# style
9+
94309b91a070d0f64755fe0a7c83e9908b5de42e
10+
11+
# Reformat the codebase
12+
2bb508ef08a0acfd0c8f8b6f8b48a240d2309740
13+
# Fix linting issues
14+
23bcec4bcabe3f1718b90e89d85cfa53d36a4445
15+
# Format docs
16+
424a17ceeccf93d92cb2e6b4062907af858854b1
17+
# Update URLs in the docs
18+
8aa6d237ac6479971ffe38608b2526ef0abe55f4
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"problemMatcher": [
3+
{
4+
"owner": "sphinx-build",
5+
"severity": "error",
6+
"pattern": [
7+
{
8+
"regexp": "^(/[^:]+):((\\d+):)?(\\sWARNING:)?\\s*(.+)$",
9+
"file": 1,
10+
"line": 3,
11+
"message": 5
12+
}
13+
]
14+
}
15+
]
16+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"problemMatcher": [
3+
{
4+
"owner": "sphinx-lint",
5+
"severity": "error",
6+
"pattern": [
7+
{
8+
"regexp": "^([^:]+):(\\d+):\\s+(.*)\\s\\(([a-z-]+)\\)$",
9+
"file": 1,
10+
"line": 2,
11+
"message": 3,
12+
"code": 4
13+
}
14+
]
15+
}
16+
]
17+
}

.github/workflows/changelog_reminder.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,24 +13,24 @@ jobs:
1313
contents: read
1414
runs-on: ubuntu-latest
1515
steps:
16-
- uses: actions/checkout@v5
16+
- uses: actions/checkout@v6
1717

1818
- name: Get all updated Python files
1919
id: changed-python-files
20-
uses: tj-actions/changed-files@v46
20+
uses: tj-actions/changed-files@v47
2121
with:
2222
files: |
2323
**.py
2424
2525
- name: Check for the changelog update
2626
id: changelog-update
27-
uses: tj-actions/changed-files@v46
27+
uses: tj-actions/changed-files@v47
2828
with:
2929
files: docs/changelog.rst
3030

3131
- name: Comment under the PR with a reminder
3232
if: steps.changed-python-files.outputs.any_changed == 'true' && steps.changelog-update.outputs.any_changed == 'false'
33-
uses: thollander/actions-comment-pull-request@v2
33+
uses: thollander/actions-comment-pull-request@v3
3434
with:
3535
message: 'Thank you for the PR! The changelog has not been updated, so here is a friendly reminder to check if you need to add an entry.'
3636
GITHUB_TOKEN: '${{ secrets.GITHUB_TOKEN }}'

.github/workflows/lint.yaml

Lines changed: 146 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,146 @@
1+
name: Lint check
2+
run-name: Lint code
3+
on:
4+
pull_request:
5+
push:
6+
branches:
7+
- master
8+
9+
concurrency:
10+
# Cancel previous workflow run when a new commit is pushed to a feature branch
11+
group: ${{ github.workflow }}-${{ github.ref }}
12+
cancel-in-progress: ${{ github.ref != 'refs/heads/master' }}
13+
14+
env:
15+
PYTHON_VERSION: "3.10"
16+
17+
jobs:
18+
changed-files:
19+
runs-on: ubuntu-latest
20+
name: Get changed files
21+
outputs:
22+
any_docs_changed: ${{ steps.changed-doc-files.outputs.any_changed }}
23+
any_python_changed: ${{ steps.raw-changed-python-files.outputs.any_changed }}
24+
changed_doc_files: ${{ steps.changed-doc-files.outputs.all_changed_files }}
25+
changed_python_files: ${{ steps.changed-python-files.outputs.all_changed_files }}
26+
steps:
27+
- uses: actions/checkout@v6
28+
- name: Get changed docs files
29+
id: changed-doc-files
30+
uses: tj-actions/changed-files@v47
31+
with:
32+
files: |
33+
docs/**
34+
- name: Get changed python files
35+
id: raw-changed-python-files
36+
uses: tj-actions/changed-files@v47
37+
with:
38+
files: |
39+
**.py
40+
poetry.lock
41+
42+
- name: Check changed python files
43+
id: changed-python-files
44+
env:
45+
CHANGED_PYTHON_FILES: ${{ steps.raw-changed-python-files.outputs.all_changed_files }}
46+
run: |
47+
if [[ " $CHANGED_PYTHON_FILES " == *" poetry.lock "* ]]; then
48+
# if poetry.lock is changed, we need to check everything
49+
CHANGED_PYTHON_FILES="."
50+
fi
51+
echo "all_changed_files=$CHANGED_PYTHON_FILES" >> "$GITHUB_OUTPUT"
52+
53+
format:
54+
if: needs.changed-files.outputs.any_python_changed == 'true'
55+
runs-on: ubuntu-latest
56+
name: Check formatting
57+
needs: changed-files
58+
steps:
59+
- uses: actions/checkout@v6
60+
- name: Install Python tools
61+
uses: BrandonLWhite/pipx-install-action@v1.0.3
62+
- uses: actions/setup-python@v6
63+
with:
64+
python-version: ${{ env.PYTHON_VERSION }}
65+
cache: poetry
66+
67+
- name: Install dependencies
68+
run: poetry install
69+
70+
- name: Check code formatting
71+
# the job output will contain colored diffs with what needs adjusting
72+
run: poe check-format --output-format=github ${{ needs.changed-files.outputs.changed_python_files }}
73+
74+
lint:
75+
if: needs.changed-files.outputs.any_python_changed == 'true'
76+
runs-on: ubuntu-latest
77+
name: Check linting
78+
needs: changed-files
79+
steps:
80+
- uses: actions/checkout@v6
81+
- name: Install Python tools
82+
uses: BrandonLWhite/pipx-install-action@v1.0.3
83+
- uses: actions/setup-python@v6
84+
with:
85+
python-version: ${{ env.PYTHON_VERSION }}
86+
cache: poetry
87+
88+
- name: Install dependencies
89+
run: poetry install
90+
91+
- name: Lint code
92+
run: poe lint --output-format=github ${{ needs.changed-files.outputs.changed_python_files }}
93+
94+
mypy:
95+
if: needs.changed-files.outputs.any_python_changed == 'true'
96+
runs-on: ubuntu-latest
97+
name: Check types with mypy
98+
needs: changed-files
99+
steps:
100+
- uses: actions/checkout@v6
101+
- name: Install Python tools
102+
uses: BrandonLWhite/pipx-install-action@v1.0.3
103+
- uses: actions/setup-python@v6
104+
with:
105+
python-version: ${{ env.PYTHON_VERSION }}
106+
cache: poetry
107+
108+
- name: Install dependencies
109+
run: poetry install
110+
111+
- name: Type check code
112+
uses: liskin/gh-problem-matcher-wrap@v3
113+
with:
114+
linters: mypy
115+
run: poe check-types --show-column-numbers --no-error-summary .
116+
117+
docs:
118+
if: needs.changed-files.outputs.any_docs_changed == 'true'
119+
runs-on: ubuntu-latest
120+
name: Check docs
121+
needs: changed-files
122+
steps:
123+
- uses: actions/checkout@v6
124+
- name: Install Python tools
125+
uses: BrandonLWhite/pipx-install-action@v1.0.3
126+
- uses: actions/setup-python@v6
127+
with:
128+
python-version: ${{ env.PYTHON_VERSION }}
129+
cache: poetry
130+
131+
- name: Install dependencies
132+
run: poetry install --extras=docs
133+
134+
- name: Add Sphinx problem matchers
135+
run: |
136+
echo "::add-matcher::.github/problem-matchers/sphinx-build.json"
137+
echo "::add-matcher::.github/problem-matchers/sphinx-lint.json"
138+
139+
- name: Check docs formatting
140+
run: poe format-docs --check
141+
142+
- name: Lint docs
143+
run: poe lint-docs
144+
145+
- name: Build docs
146+
run: poe docs -- -e 'SPHINXOPTS=--fail-on-warning --keep-going'

.github/workflows/main.yml

Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,45 @@
1-
name: Python Tests
2-
3-
on: [push]
4-
1+
name: Test
2+
on:
3+
pull_request:
4+
push:
5+
branches:
6+
- main
57

68
jobs:
79
test:
810
name: Run tests
9-
runs-on: ubuntu-latest
11+
permissions:
12+
id-token: write
1013
strategy:
14+
fail-fast: false
1115
matrix:
12-
python: ["3.9", "3.10", "3.11", "3.12", "3.13", "3.14"]
16+
platform: [ubuntu-latest, windows-latest]
17+
python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"]
18+
runs-on: ${{ matrix.platform }}
1319
steps:
14-
- uses: actions/checkout@v4
20+
- uses: actions/checkout@v6
1521
- name: Install Python tools
1622
uses: BrandonLWhite/pipx-install-action@v1.0.3
1723
- name: Setup Python with poetry caching
1824
# poetry cache requires poetry to already be installed, weirdly
19-
uses: actions/setup-python@v5
25+
uses: actions/setup-python@v6
2026
with:
2127
python-version: ${{ matrix.python-version }}
2228
cache: poetry
2329

2430
- name: Test
2531
run: |-
2632
poetry install
27-
poe test
33+
poe test-with-coverage
34+
35+
- name: Upload test results to Codecov
36+
uses: codecov/test-results-action@v1
37+
with:
38+
token: ${{ secrets.CODECOV_TOKEN }}
39+
40+
- name: Upload code coverage
41+
uses: codecov/codecov-action@v5
42+
with:
43+
files: ./coverage.xml
44+
flags: ${{ matrix.platform}}_python${{ matrix.python-version }}
45+
use_oidc: ${{ !(github.event_name == 'pull_request' && github.event.pull_request.head.repo.fork) }}

.github/workflows/make_release.yaml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ on:
88
required: true
99

1010
env:
11-
PYTHON_VERSION: 3.9
11+
PYTHON_VERSION: 3.10
1212
NEW_VERSION: ${{ inputs.version }}
1313
NEW_TAG: v${{ inputs.version }}
1414

@@ -17,10 +17,10 @@ jobs:
1717
name: Bump version, commit and create tag
1818
runs-on: ubuntu-latest
1919
steps:
20-
- uses: actions/checkout@v4
20+
- uses: actions/checkout@v6
2121
- name: Install Python tools
2222
uses: BrandonLWhite/pipx-install-action@v1.0.3
23-
- uses: actions/setup-python@v5
23+
- uses: actions/setup-python@v6
2424
with:
2525
python-version: ${{ env.PYTHON_VERSION }}
2626
cache: poetry
@@ -40,13 +40,13 @@ jobs:
4040
runs-on: ubuntu-latest
4141
needs: increment-version
4242
steps:
43-
- uses: actions/checkout@v4
43+
- uses: actions/checkout@v6
4444
with:
4545
ref: ${{ env.NEW_TAG }}
4646

4747
- name: Install Python tools
4848
uses: BrandonLWhite/pipx-install-action@v1.0.3
49-
- uses: actions/setup-python@v5
49+
- uses: actions/setup-python@v6
5050
with:
5151
python-version: ${{ env.PYTHON_VERSION }}
5252
cache: poetry
@@ -55,7 +55,7 @@ jobs:
5555
run: poetry build
5656

5757
- name: Store the package
58-
uses: actions/upload-artifact@v4
58+
uses: actions/upload-artifact@v6
5959
with:
6060
name: python-package-distributions
6161
path: dist/
@@ -71,7 +71,7 @@ jobs:
7171
id-token: write
7272
steps:
7373
- name: Download all the dists
74-
uses: actions/download-artifact@v4
74+
uses: actions/download-artifact@v7
7575
with:
7676
name: python-package-distributions
7777
path: dist/

0 commit comments

Comments
 (0)