Skip to content

Commit 11a43bf

Browse files
committed
Type-check the scripts on the newest supported Python
`Python - Check code style` fails on `main` because the scripts import the `docs` dependency group, which installs Sphinx and nbsphinx only on Python 3.13+ (Sphinx 9.1+ requires it), while that job lints on the oldest supported Python. Installing the group there resolves to nothing, which is what the earlier attempt assumed was enough. The scripts are dev tooling rather than library code, so a `code-style-scripts` job type-checks them on the newest supported Python (3.15) with the group installed. The mypy config skips the directory for the oldest-Python job, and the new job names the files, since `exclude` applies to a directory target as well. `MYPYPATH` resolves the test harness that the notebook scripts import from `python-wrapper/tests`. `--group docs` on `code-style` goes: it is a no-op on 3.11 and the group belongs to the new job.
1 parent 063432d commit 11a43bf

2 files changed

Lines changed: 44 additions & 2 deletions

File tree

‎.github/workflows/py-code-style.yml‎

Lines changed: 39 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,49 @@ jobs:
4646
python-version: "3.11"
4747
enable-cache: true
4848
- run: uv venv
49-
# --group docs: mypy type-checks the docs tooling, which imports nbsphinx and sphinx.
50-
- run: uv sync --group dev --group docs --extra pandas --extra neo4j --extra gds --extra snowflake
49+
- run: uv sync --group dev --extra pandas --extra neo4j --extra gds --extra snowflake
5150

5251
- name: Check code style
5352
run: source .venv/bin/activate && cd ${GITHUB_WORKSPACE} && ./scripts/checkstyle.sh
5453

54+
# Type-check the repository's scripts, which `code-style` cannot: they import the `docs`
55+
# dependency group (Sphinx and nbsphinx install only on Python 3.13+) and are dev tooling
56+
# rather than library code, so they are checked on the newest supported Python. The mypy
57+
# config excludes `scripts/` for that reason, and `MYPYPATH` resolves the test harness that
58+
# the notebook scripts import from `python-wrapper/tests`.
59+
code-style-scripts:
60+
runs-on: ubuntu-latest
61+
62+
defaults:
63+
run:
64+
working-directory: python-wrapper
65+
66+
steps:
67+
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
68+
- name: Patch eMudhra CA compromise (CVE-2026-111943)
69+
shell: bash
70+
working-directory: .
71+
run: |
72+
sudo apt-get update
73+
sudo apt-get install --only-upgrade -y ca-certificates
74+
sudo update-ca-certificates --fresh
75+
76+
- name: Install uv and set the Python version
77+
uses: astral-sh/setup-uv@68559e99cc807c1eb7e9238fd43a15bba460eec2 # v10.3.3
78+
with:
79+
python-version: "3.15"
80+
enable-cache: true
81+
82+
- name: Type-check the scripts
83+
# Files rather than the directory: mypy's `exclude` applies to a directory target too,
84+
# while files named on the command line are checked regardless. `MYPYPATH` resolves the
85+
# test harness the notebook scripts import from `python-wrapper/tests`.
86+
run: |
87+
cd ${GITHUB_WORKSPACE}
88+
MYPYPATH=python-wrapper uv run --project python-wrapper --group docs \
89+
python -m mypy --config-file python-wrapper/pyproject.toml \
90+
$(git ls-files 'scripts/*.py' 'scripts/**/*.py')
91+
5592
# Type-check the v1 (1.22) side of the GDS compat surface.
5693
code-style-gds-v1:
5794
runs-on: ubuntu-latest

‎python-wrapper/pyproject.toml‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,11 @@ strict = true
191191
exclude = [
192192
'(^build|^\.?venv)',
193193
'build',
194+
# The scripts are dev tooling rather than library code: they import the `docs` dependency
195+
# group (Sphinx and nbsphinx install only on Python 3.13+), which `code-style` cannot
196+
# install on the oldest supported Python it lints with. The `code-style-scripts` job checks
197+
# them on the newest supported Python instead.
198+
'^scripts/',
194199
]
195200
plugins = ['pydantic.mypy']
196201
untyped_calls_exclude=["nbconvert"]

0 commit comments

Comments
 (0)