Skip to content

Type-check the scripts on the newest supported Python - #524

Merged
FlorentinD merged 1 commit into
mainfrom
fix-style-docs-imports
Nov 23, 2026
Merged

FlorentinD merged 1 commit into
mainfrom
fix-style-docs-imports

Conversation

@FlorentinD

@FlorentinD FlorentinD commented Nov 23, 2026 •

Copy link
Copy Markdown
Collaborator

Python - Check code style fails on main, with three errors in scripts/sphinx_container_pandoc.py:

:85: error: Unused "type: ignore" comment  [unused-ignore]
:85: error: Cannot find implementation or library stub for module named "nbsphinx"  [import-not-found]
:112: error: Cannot find implementation or library stub for module named "sphinx.cmd.build"  [import-not-found]

The job lints on Python 3.11, but the scripts import the docs dependency group, which installs Sphinx and nbsphinx only on Python 3.13+ (Sphinx 9.1+ requires it). An earlier attempt added --group docs to that job's sync, which resolves to nothing there — every entry in the group is gated on the interpreter version — so the job still fails. The line is dropped again here.

The scripts are dev tooling rather than library code, and the justfile runs them from a uv-managed environment, so they are type-checked on the newest supported Python instead. A new code-style-scripts job does that on 3.15 with the docs group installed, and code-style keeps linting the library on the oldest supported Python, which is where 3.11 compatibility is checked.

The mypy config skips scripts/ for the oldest-Python job. The new job names the files rather than the directory, since exclude applies to a directory target as well, and sets MYPYPATH so the test harness the notebook scripts import from python-wrapper/tests resolves.

Considerations: the scripts are no longer type-checked against Python 3.11. They are run from a uv-managed venv rather than by end users, and clean_notebooks.py is still executed by the 3.11 job for the notebook formatting check, so an actual 3.11 incompatibility there would still fail. If the scripts should gate merges, code-style-scripts may need adding to the required checks.

@FlorentinD
FlorentinD requested a review from a team as a code owner November 23, 2026 16:48
@FlorentinD
FlorentinD force-pushed the fix-style-docs-imports branch 2 times, most recently from 6307d4a to c43c271 Compare November 23, 2026 16:52
@FlorentinD FlorentinD changed the title Let mypy ignore the docs imports the style job cannot install Check the docs tooling in a job that has the docs dependencies Nov 23, 2026
`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.
@FlorentinD
FlorentinD force-pushed the fix-style-docs-imports branch from c43c271 to efae84a Compare November 23, 2026 17:03
@FlorentinD FlorentinD changed the title Check the docs tooling in a job that has the docs dependencies Type-check the scripts on the newest supported Python Nov 23, 2026
@FlorentinD
FlorentinD merged commit 11a43bf into main Nov 23, 2026
15 checks passed
@FlorentinD
FlorentinD deleted the fix-style-docs-imports branch November 23, 2026 17:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant