Skip to content

Commit 2348f4e

Browse files
jhaleclaude
andcommitted
Split typing stubs into a standalone extra
Separate types-cffi/types-setuptools/scipy-stubs into a new `typing` extra, installable independently by downstream users type-checking their own code against the DOLFINx API, regardless of which type checker they use. Drop the now-trivial `mypy` dependency group in favour of listing `mypy` and `fenics-dolfinx[typing]` directly where needed. Also install the typing stubs in the ci.yml mypy venv, which previously checked with no stub coverage at all. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
1 parent 130ecfc commit 2348f4e

4 files changed

Lines changed: 12 additions & 7 deletions

File tree

.github/workflows/ci.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,10 @@ jobs:
237237
# dolfinx, petsc4py and the rest.
238238
apt-get install -y --no-install-recommends python3-venv
239239
python3 -m venv /tmp/mypy-venv
240-
/tmp/mypy-venv/bin/pip install --quiet mypy
240+
# types-cffi, types-setuptools and scipy-stubs mirror the `typing`
241+
# extra in python/pyproject.toml; installed by name rather than via
242+
# '.[typing]' to avoid triggering a full DOLFINx build in this venv.
243+
/tmp/mypy-venv/bin/pip install --quiet mypy types-cffi types-setuptools scipy-stubs
241244
# Distinguishes a broken install from mypy reporting errors.
242245
/tmp/mypy-venv/bin/mypy --version
243246
ENV_PYTHON=$(command -v python)

AGENTS.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -262,10 +262,10 @@ disclosure process.
262262
for parallel-aware tests where relevant.
263263
- Run the relevant formatter/linter and the affected test suite before
264264
calling a change done — don't rely on CI to catch formatting.
265-
- Dependency groups (`build`, `docs`, `lint`, `mypy`, `test`, `ci` in
265+
- Dependency groups (`build`, `docs`, `lint`, `test`, `ci` in
266266
`python/pyproject.toml`) use PEP 735 syntax and require `pip >= 25.1`
267267
(or another PEP 735-compliant build frontend) for the `--group` flag.
268-
`demo`, `optional`, and `petsc4py` remain real
268+
`demo`, `optional`, `petsc4py`, and `typing` remain real
269269
`[project.optional-dependencies]` extras since they are user-facing
270270
runtime features, or (in the case of `test`) are installed against
271271
built wheels where dependency groups are unavailable.

python/README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,10 @@ Note that Developer mode is significantly stricter than CMake's default Debug mo
2020

2121
# Type checking with mypy
2222

23-
1. Install DOLFINx Python with the `mypy` dependency group, e.g.:
23+
1. Install DOLFINx Python with the `typing` extra, plus `mypy` itself
24+
(or any other type checker), e.g.:
2425

25-
pip install --group mypy .
26+
pip install mypy '.[typing]'
2627

2728
2. Check with mypy, e.g.:
2829

python/pyproject.toml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ optional = [
4646
"numba; (sys_platform != 'darwin' or platform_machine != 'x86_64') and (sys_platform != 'win32' or platform_machine != 'ARM64')",
4747
]
4848
petsc4py = ["petsc4py"]
49+
typing = ["types-cffi", "types-setuptools", "scipy-stubs"]
4950

5051
[dependency-groups]
5152
# Keep in sync with [build-system].requires above (petsc4py is an
@@ -73,15 +74,15 @@ docs = [
7374
"fenics-dolfinx[demo]",
7475
]
7576
lint = ["ruff", "gersemi"]
76-
mypy = ["mypy", "types-cffi", "types-setuptools", "scipy-stubs"]
7777
ci = [
7878
"pytest-xdist",
79+
"mypy",
7980
{ include-group = "build" },
8081
{ include-group = "docs" },
8182
{ include-group = "lint" },
82-
{ include-group = "mypy" },
8383
{ include-group = "test" },
8484
"fenics-dolfinx[optional]",
85+
"fenics-dolfinx[typing]",
8586
]
8687

8788
[tool.scikit-build]

0 commit comments

Comments
 (0)