Skip to content

Commit 2acb397

Browse files
authored
🚸 change to nox -s stubs for driving stub generation (#288)
* 🚸 change to `nox -s stubs` for driving stub generation Signed-off-by: burgholzer <[email protected]> * 📝 prepare release notes Signed-off-by: burgholzer <[email protected]> * ✏️ update docs to reflect new stub generation check requirement Signed-off-by: burgholzer <[email protected]> * 👌 address CodeRabbit comments Signed-off-by: burgholzer <[email protected]> --------- Signed-off-by: burgholzer <[email protected]>
1 parent 654680a commit 2acb397

File tree

3 files changed

+74
-9
lines changed

3 files changed

+74
-9
lines changed

.github/workflows/reusable-python-linter.yml

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ on:
3535
default: "21.1.7"
3636
type: string
3737
check-stubs:
38-
description: "Whether to check if the stub files are up to date. Requires 'bindings/generate-stubs.sh' to exist"
38+
description: "Whether to check if the stub files are up to date. Requires a nox session called `stubs` to exist."
3939
default: false
4040
type: boolean
4141

@@ -71,13 +71,9 @@ jobs:
7171
- name: Check if stub files are up to date
7272
if: ${{ inputs.check-stubs }}
7373
run: |
74-
if [[ ! -f ./bindings/generate-stubs.sh ]]; then
75-
echo "'./bindings/generate-stubs.sh' not found. Please disable the 'check-stubs' input or create a stub-generation script."
76-
exit 1
77-
fi
78-
./bindings/generate-stubs.sh || true
74+
uvx nox -s stubs
7975
if [[ $(git status --porcelain python) ]]; then
80-
echo "Stub files are not up to date. Please run './bindings/generate-stubs.sh' and commit the changes."
76+
echo "Stub files are not up to date. Please run 'nox -s stubs' and commit the changes."
8177
git --no-pager diff python
8278
exit 1
8379
fi

CHANGELOG.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,14 @@ This project adheres to [Semantic Versioning], with the exception that minor rel
99

1010
## [Unreleased]
1111

12+
## [1.17.6] - 2025-12-21
13+
14+
_If you are upgrading: please see [`UPGRADING.md`](UPGRADING.md#1176)._
15+
16+
### Changed
17+
18+
- 🚸 change to `nox -s stubs` for driving stub generation ([#288]) ([**@burgholzer**])
19+
1220
## [1.17.5] - 2025-12-19
1321

1422
_If you are upgrading: please see [`UPGRADING.md`](UPGRADING.md#1175)._
@@ -196,7 +204,8 @@ _📚 Refer to the [GitHub Release Notes] for previous changelogs._
196204

197205
<!-- Version links -->
198206

199-
[unreleased]: https://github.com/munich-quantum-toolkit/workflows/compare/v1.17.5...HEAD
207+
[unreleased]: https://github.com/munich-quantum-toolkit/workflows/compare/v1.17.6...HEAD
208+
[1.17.6]: https://github.com/munich-quantum-toolkit/workflows/releases/tag/v1.17.6
200209
[1.17.5]: https://github.com/munich-quantum-toolkit/workflows/releases/tag/v1.17.5
201210
[1.17.4]: https://github.com/munich-quantum-toolkit/workflows/releases/tag/v1.17.4
202211
[1.17.3]: https://github.com/munich-quantum-toolkit/workflows/releases/tag/v1.17.3
@@ -218,6 +227,7 @@ _📚 Refer to the [GitHub Release Notes] for previous changelogs._
218227

219228
<!-- PR links -->
220229

230+
[#288]: https://github.com/munich-quantum-toolkit/workflows/pull/288
221231
[#286]: https://github.com/munich-quantum-toolkit/workflows/pull/286
222232
[#276]: https://github.com/munich-quantum-toolkit/workflows/pull/276
223233
[#271]: https://github.com/munich-quantum-toolkit/workflows/pull/271

UPGRADING.md

Lines changed: 60 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,64 @@ This document describes breaking changes and how to upgrade. For a complete list
44

55
## [Unreleased]
66

7+
## [1.17.6]
8+
9+
### Checking Python stub files
10+
11+
The optional Python linter workflow for checking Python stub files has been redesigned to rely on the presence of a nox session called `stubs`, that shall generate the stub files.
12+
An example of such a session would be:
13+
14+
```python
15+
import nox
16+
import shutil
17+
from pathlib import Path
18+
19+
@nox.session(reuse_venv=True, venv_backend="uv")
20+
def stubs(session: nox.Session) -> None:
21+
"""Generate type stubs for Python bindings using nanobind."""
22+
env = {"UV_PROJECT_ENVIRONMENT": session.virtualenv.location}
23+
session.run(
24+
"uv",
25+
"sync",
26+
env=env,
27+
)
28+
29+
from nanobind.stubgen import main as nanobind_main # type: ignore[import-not-found]
30+
31+
package_root = Path(__file__).parent / "python" / "mqt" / "core"
32+
pattern_file = Path(__file__).parent / "bindings" / "core_patterns.txt"
33+
34+
args = [
35+
"--recursive",
36+
"--include-private",
37+
"--output-dir",
38+
str(package_root),
39+
"--pattern-file",
40+
str(pattern_file),
41+
"--module",
42+
"mqt.core.ir",
43+
"--module",
44+
"mqt.core.dd",
45+
"--module",
46+
"mqt.core.fomac",
47+
"--module",
48+
"mqt.core.na",
49+
]
50+
51+
nanobind_main(args)
52+
53+
pyi_files = list(package_root.glob("**/*.pyi"))
54+
55+
if shutil.which("prek") is None:
56+
session.install("prek")
57+
58+
success_codes = [0, 1]
59+
session.run("prek", "run", "license-tools", "--files", *pyi_files, external=True, success_codes=success_codes)
60+
session.run("prek", "run", "ruff-check", "--files", *pyi_files, external=True, success_codes=success_codes)
61+
session.run("prek", "run", "ruff-format", "--files", *pyi_files, external=True, success_codes=success_codes)
62+
session.run("prek", "run", "ruff-check", "--files", *pyi_files, external=True)
63+
```
64+
765
## [1.17.5]
866

967
### MLIR support
@@ -196,7 +254,8 @@ Consider removing any `-G Ninja` flags from your CMake invocations under Windows
196254

197255
<!-- Version links -->
198256

199-
[unreleased]: https://github.com/munich-quantum-toolkit/workflows/compare/v1.17.5...HEAD
257+
[unreleased]: https://github.com/munich-quantum-toolkit/workflows/compare/v1.17.6...HEAD
258+
[1.17.6]: https://github.com/munich-quantum-toolkit/workflows/releases/tag/v1.17.6
200259
[1.17.5]: https://github.com/munich-quantum-toolkit/workflows/compare/v1.17.3...v1.17.5
201260
[1.17.3]: https://github.com/munich-quantum-toolkit/workflows/compare/v1.17.0...v1.17.3
202261
[1.17.0]: https://github.com/munich-quantum-toolkit/workflows/compare/v1.16.0...v1.17.0

0 commit comments

Comments
 (0)