Skip to content

♻️ Auto-generate stub file#831

Merged
denialhaag merged 8 commits intomainfrom
auto-stubs
Jan 26, 2026
Merged

♻️ Auto-generate stub file#831
denialhaag merged 8 commits intomainfrom
auto-stubs

Conversation

@denialhaag
Copy link
Member

@denialhaag denialhaag commented Jan 25, 2026

Description

After we have switched from pybind11 to nanobind in #817, we can now auto-generate the stub file. This PR defines a corresponding nox session and copies over all existing docstrings to the bindings code.

Checklist:

  • The pull request only contains commits that are focused and relevant to this change.
  • I have added appropriate tests that cover the new/changed functionality.
  • I have updated the documentation to reflect these changes.
  • I have added entries to the changelog for any noteworthy additions, changes, fixes, or removals.
  • I have added migration instructions to the upgrade guide (if needed).
  • The changes follow the project's style guidelines and introduce no new warnings.
  • The changes are fully tested and pass the CI checks.
  • I have reviewed my own code changes.

@denialhaag denialhaag self-assigned this Jan 25, 2026
@denialhaag denialhaag added python Anything related to Python code c++ Anything related to C++ code minor Part of a minor release labels Jan 25, 2026
@github-project-automation github-project-automation bot moved this to In Progress in MQT Verification Jan 25, 2026
@codecov
Copy link

codecov bot commented Jan 25, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 25, 2026

Warning

Rate limit exceeded

@denialhaag has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 8 minutes and 45 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📝 Walkthrough

Walkthrough

Replace legacy pybind11 binding files with new nanobind register_* bindings, add generated Python stubs (.pyi) and a nox stubs session, enable stub checking in CI, update typing/stub-related lint rules, adjust license exclusions, and update tests/docs to reflect renamed enum members and generated stubs.

Changes

Cohort / File(s) Summary
Removed legacy bindings
bindings/application_scheme.cpp, bindings/configuration.cpp, bindings/equivalence_checking_manager.cpp, bindings/equivalence_criterion.cpp, bindings/state_type.cpp
Deleted old pybind11 binding implementations that exposed enums/classes to Python. Verify no remaining references to the removed symbols.
Added nanobind bindings
bindings/register_application_scheme.cpp, bindings/register_configuration.cpp, bindings/register_equivalence_checking_manager.cpp, bindings/register_equivalence_criterion.cpp, bindings/register_state_type.cpp
New nanobind register* files reintroduce the binding surface (ApplicationScheme, StateType, EquivalenceCriterion, Configuration, EquivalenceCheckingManager + Results). Review API names, docs, property/json conversions, and ABI compatibility.
Bindings initialization update
bindings/bindings.cpp
Renamed forward-declaration and call from registerApplicationSchemaregisterApplicationScheme to match new registration function name.
Generated stubs & patterns
bindings/qcec_patterns.txt, python/mqt/qcec/pyqcec.pyi
Added pattern file entries and a large auto-generated .pyi. Enums converted to IntEnum with explicit integer values; Configuration and nested classes now use property-based API; EquivalenceCheckingManager gained nested Results; type hints fully qualified. Validate that stubs match runtime bindings.
CI & tooling
.github/workflows/ci.yml, noxfile.py, pyproject.toml
CI python-linter step now passes check-stubs: true; added a nox stubs session (duplicated entry present); updated per-file lint ignores for *.pyi. Check duplicate stubs declaration and CI consistency.
License, tests & docs
.license-tools-config.json, test/python/test_configuration.py, CHANGELOG.md, UPGRADING.md
Excluded qcec_patterns.txt from license checks; updated test parameterization for StateType.random_1q_basis; added changelog and upgrading note about enum rename and stub generation. Confirm tests align with new API names.

Sequence Diagram(s)

(Skipped)

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

Suggested labels

c++

Suggested reviewers

  • burgholzer

"I hopped through headers, paws on keys,
Enums now numbered, stubs on breeze.
Bindings reborn with careful art,
CI hums, docs sing — a brand new start. 🐇"

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.86% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title concisely summarizes the main change: auto-generating stub files. It accurately reflects the PR's primary objective and is clear and specific.
Description check ✅ Passed The PR description comprehensively explains the motivation, changes, and includes a completed checklist. It references the prior switch to nanobind and clearly states the purpose of enabling auto-generation.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Fix all issues with AI agents
In `@bindings/register_application_scheme.cpp`:
- Line 21: Rename the registration function to match the enum name: change
registerApplicationSchema to registerApplicationScheme (note "Scheme" not
"Schema") in the function definition and its forward declaration, and update all
call sites that reference registerApplicationSchema to use
registerApplicationScheme so the symbol matches the enum ApplicationScheme.

In `@noxfile.py`:
- Around line 204-237: Before running nanobind.stubgen, remove any previously
generated stubs under package_root to avoid stale .pyi files; locate the
package_root and pattern_file variables and the session.run call that invokes
"python -m nanobind.stubgen", then add a cleanup step that deletes existing .pyi
files or the target directory (e.g., remove Path(package_root)/*.pyi or the
whole generated tree) prior to the stubgen session.run so the subsequent listing
into pyi_files reflects only newly generated stubs.

@denialhaag denialhaag changed the title ♻️ Auto-generate stub files ♻️ Auto-generate stub file Jan 25, 2026
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@bindings/register_equivalence_checking_manager.cpp`:
- Around line 11-20: The code calls nlohmann::json::parse (used in
EquivalenceCheckingManager code) but does not include the nlohmann/json header;
add the missing include for nlohmann/json.hpp near the other includes (alongside
Configuration.hpp, EquivalenceCheckingManager.hpp, etc.) so the call to
nlohmann::json::parse is not relying on fragile transitive includes and will
compile reliably.

@denialhaag denialhaag requested a review from burgholzer January 26, 2026 00:43
@denialhaag denialhaag added enhancement Anything related to improvements of the existing library and removed c++ Anything related to C++ code labels Jan 26, 2026
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@noxfile.py`:
- Around line 221-225: The code currently calls session.warn("No .pyi files
found") and returns when pyi_files is empty, which lets the session exit
successfully; change this to fail the session by replacing the warn+return with
a hard failure (e.g., call session.error("No .pyi files found") or raise
SystemExit/RuntimeError) so missing stubs cause a nonzero exit; update the block
that checks pyi_files (the variables pyi_files and package_root and the session
call) to invoke session.error with a clear message instead of session.warn and
remove the silent return.

Copy link
Member

@burgholzer burgholzer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great. Just noticed one small inconsistency.

@denialhaag denialhaag enabled auto-merge (squash) January 26, 2026 01:42
@denialhaag denialhaag merged commit 3eb8e2f into main Jan 26, 2026
31 of 32 checks passed
@denialhaag denialhaag deleted the auto-stubs branch January 26, 2026 03:45
@github-project-automation github-project-automation bot moved this from In Progress to Done in MQT Verification Jan 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement Anything related to improvements of the existing library minor Part of a minor release python Anything related to Python code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants