Skip to content

🔧 Replace mypy with ty - #912

Merged
denialhaag merged 7 commits into
mainfrom
ty
Jan 17, 2026
Merged

🔧 Replace mypy with ty#912
denialhaag merged 7 commits into
mainfrom
ty

Conversation

@denialhaag

@denialhaag denialhaag commented Jan 15, 2026

Copy link
Copy Markdown
Member

Description

This PR replaces mypy with ty.

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 15, 2026
@denialhaag denialhaag added the dependencies Pull requests that update a dependency file label Jan 15, 2026
@denialhaag denialhaag added python Anything related to Python code code quality Anything related to code quality and code style. labels Jan 15, 2026
@github-project-automation github-project-automation Bot moved this to In Progress in MQT Compilation Jan 15, 2026
@coderabbitai

coderabbitai Bot commented Jan 15, 2026

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Summary by CodeRabbit

  • New Features

    • Enhanced interactive visualization using Plotly FigureWidget.
  • Chores

    • Migrated static type checking from mypy to ty and added ty as a dev dependency.
    • Updated CI/type-check workflow flags and pre-commit hook configuration.
    • Switched backend integration to a newer backend API.
  • Tests

    • Added runtime assertions in tests and removed an example test file.
  • Docs

    • Updated changelog entry.

✏️ Tip: You can customize this high-level summary in your review settings.

Walkthrough

Replace mypy with ty across CI, pre-commit, and pyproject; switch Qiskit typing to BackendV2/Target; adapt tableau attribute names; migrate visualization to Plotly FigureWidget; add runtime test assertions; remove an example test file; update CHANGELOG.

Changes

Cohort / File(s) Summary
CI workflow invocation
\.github/workflows/ci.yml
Added invocation flags enable-ty: true and enable-mypy: false for the reusable python-linter job.
Pre-commit & hook config
\.pre-commit-config.yaml
Removed remote mypy hook; added local ty-check hook; updated ci.skip from [mypy] to [ty-check].
Project metadata & ty config
pyproject.toml
Removed [tool.mypy] block; added [tool.ty.*] config and ty==0.0.12 dev dependency; updated [tool.repo-review] ignores (MY100, PC140).
Qiskit backend typing updates
python/mqt/qmap/plugins/qiskit/sc/load_architecture.py, python/mqt/qmap/plugins/qiskit/sc/compile.py, python/mqt/qmap/plugins/qiskit/sc/subarchitectures.py
Replace Backend/BackendProperties usages with BackendV2/Target where applicable; update type hints and isinstance checks; remove SubarchitectureOrder.from_backend.
Compile API changes
python/mqt/qmap/plugins/qiskit/sc/compile.py
compile(...) signature: arch may be BackendV2; calibration restricted to Target.
Tableau field name adjustments
python/mqt/qmap/plugins/qiskit/clifford_synthesis.py
Access tableau.stab / tableau.destab and use .to_labels() instead of stabilizer/destabilizer.
Visualization → FigureWidget
python/mqt/qmap/visualization/visualize_search_graph.py
_visualize_layout now expects go.FigureWidget; updated callback typings, trace handling, non-None assertions, and widget update patterns.
Tests — assertions & removals
test/python/clifford_synthesis/test_clifford_synthesis.py, test/python/test.py
Added runtime assert ... is not None preconditions in tests; removed example file test/python/test.py.
Changelog
CHANGELOG.md
Added Unreleased entry "Replace mypy with ty" and PR links.

Sequence Diagram(s)

(omitted)

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • burgholzer

Poem

🐇 I hopped from mypy's shaded glen,

to ty's bright field and back again.
BackendV2 gives a joyful spin,
widgets wiggle, tableaux grin,
I nibble bugs and hop to win.

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: replacing mypy with ty as the project's type checker.
Description check ✅ Passed The PR description is minimal but covers the essential change. Most checklist items are marked complete; documentation/tests are appropriately marked as not applicable.
Docstring Coverage ✅ Passed Docstring coverage is 82.61% which is sufficient. The required threshold is 80.00%.

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

✨ Finishing touches
  • 📝 Generate docstrings

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.

@denialhaag
denialhaag requested a review from burgholzer January 15, 2026 12:57

@burgholzer burgholzer left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This looks great. I just have one comment that I was not quite sure about.

Comment thread python/mqt/qmap/plugins/qiskit/sc/subarchitectures.py Outdated
@codecov

codecov Bot commented Jan 16, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

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 `@python/mqt/qmap/plugins/qiskit/sc/load_architecture.py`:
- Around line 18-21: Update the load_architecture docstring to mention BackendV2
explicitly: in the function load_architecture(arch: str | Arch | Architecture |
BackendV2 | None = None) replace the line that currently says “or Backend” with
“or BackendV2” (or a phrase like “or BackendV2 backend”) and ensure the first
sentence clearly lists the accepted types (str, Arch, Architecture, or
BackendV2) and that passing None loads no architecture.

In `@python/mqt/qmap/visualization/visualize_search_graph.py`:
- Around line 1164-1166: The type check for search_edges_width currently rejects
integers by requiring float; update the validation to accept any numeric type
(e.g., int or float or better numbers.Real) and still enforce > 0, changing the
error message to "must be a positive number"; apply the same fix to the
analogous validation for search_stems_width (the checks around the symbols
search_edges_width and search_stems_width).

Comment thread python/mqt/qmap/plugins/qiskit/sc/load_architecture.py
Comment thread python/mqt/qmap/visualization/visualize_search_graph.py
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

code quality Anything related to code quality and code style. dependencies Pull requests that update a dependency file python Anything related to Python code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants