Skip to content

🚨 Enable Astral's type checker ty#1333

Merged
burgholzer merged 8 commits intomainfrom
enable-ty
Nov 24, 2025
Merged

🚨 Enable Astral's type checker ty#1333
burgholzer merged 8 commits intomainfrom
enable-ty

Conversation

@burgholzer
Copy link
Member

Description

This PR enables running Astral's newest project ty, a type checker meant to replace mypy and similar tools.
For the moment, this is added in addition to mypy and does not yet replace it entirely.
Once ty moves out of alpha status officially, we will completely remove mypy. That is also when we will update the documentation and the development guide.

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.

Signed-off-by: burgholzer <burgholzer@me.com>
Signed-off-by: burgholzer <burgholzer@me.com>
Signed-off-by: burgholzer <burgholzer@me.com>
Signed-off-by: burgholzer <burgholzer@me.com>
@burgholzer burgholzer added this to the MQT Core milestone Nov 24, 2025
@burgholzer burgholzer self-assigned this Nov 24, 2025
@burgholzer burgholzer added code quality Code quality improvements python Anything related to Python code labels Nov 24, 2025
@codecov
Copy link

codecov bot commented Nov 24, 2025

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 Nov 24, 2025

📝 Walkthrough

Walkthrough

This pull request updates reusable GitHub Actions workflows from v1.17.1 to v1.17.2 across CI/CD pipelines, integrates Ty (a Python type checker) as a new linting tool via pre-commit and project configuration, and adds type-casting and layout validation assertions to the Qiskit plugin code.

Changes

Cohort / File(s) Summary
GitHub Actions workflow version bumps
.github/workflows/ci.yml, .github/workflows/cd.yml, .github/workflows/upstream.yml
Updated reusable workflow references from commit 4845865ca25c2da3374981f47ae9ed9607a30e1c (v1.17.1) to ea4fccbb432596cbb6840a9608d6376b6b2c8ff7 (v1.17.2) across change-detection, cpp/tests, cpp-coverage, cpp-linter, python-tests, python-coverage, python-linter, packaging, and related workflows.
Python-linter job enhancement
.github/workflows/ci.yml
Added with block containing enable-ty: true parameter to the python-linter job invocation.
Ty type checker tool integration
.pre-commit-config.yaml
Expanded pre-commit skip list from [mypy] to [mypy, ty-check]; added new local pre-commit hook ty-check with entry uvx ty check . to run system-wide on all files.
Ty project configuration
pyproject.toml
Added [tool.ty.terminal] section with error-on-warning = true and [tool.ty.src] section with exclude = ["docs/**", "eval/**", "mlir/**"].
Qiskit plugin type and validation updates
python/mqt/core/plugins/qiskit/qiskit_to_mqt.py
Added cast of instruction to IfElseOp before passing to _add_if_else_operation in _emplace_operation; added assertion ensuring circ.layout is not None at start of _import_layouts.
Qiskit plugin test layout assertions
test/python/plugins/test_qiskit.py
Added assertions in two tests to validate that qc_transpiled.layout is not None before accessing layout-derived properties.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Areas requiring attention:

  • Verify the purpose and configuration of the new Ty type checker tool and whether exclusions in pyproject.toml are appropriate.
  • Confirm that the IfElseOp cast in qiskit_to_mqt.py is type-safe and handles all instruction types correctly.
  • Review the new layout assertions in tests to ensure they don't introduce false failures when circuit layout is legitimately unavailable.
  • Validate that enabling enable-ty: true in the python-linter workflow is intended and won't produce unexpected linting failures in CI.

Poem

🐰 Ty's arrival brings checks so fine,
With workflows bumped to v1.17.2's design,
Type casts and assertions take their place,
Pre-commit hooks help set the pace,
Code quality hops along with grace!

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the main change: enabling Astral's type checker 'ty' across the project. It accurately reflects the primary objective of the PR.
Description check ✅ Passed The PR description follows the template structure with a comprehensive description section and completed checklist. It explains the purpose, scope, and future plans for the 'ty' integration.
✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch enable-ty

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0eddc6c and 05c1bda.

📒 Files selected for processing (4)
  • .github/workflows/cd.yml (2 hunks)
  • .github/workflows/ci.yml (12 hunks)
  • .github/workflows/upstream.yml (2 hunks)
  • pyproject.toml (1 hunks)
⏰ Context from checks skipped due to timeout of 900000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (7)
  • GitHub Check: 🚀 CD (windows-2022) / 🎡 windows-2022
  • GitHub Check: 🚀 CD (windows-11-arm) / 🎡 windows-11-arm
  • GitHub Check: 🐍 Test (macos-14) / 🐍 macos-14
  • GitHub Check: 🚀 CD (macos-15-intel) / 🎡 macos-15-intel
  • GitHub Check: 🐍 Test (windows-2022) / 🐍 windows-2022
  • GitHub Check: 🐍 Test (macos-15-intel) / 🐍 macos-15-intel
  • GitHub Check: 🐍⚛️ (windows-2022) / 🐍⚛️ windows-2022
🔇 Additional comments (5)
pyproject.toml (1)

300-310: ✅ ty configuration is well-structured and appropriate.

The new [tool.ty.terminal] and [tool.ty.src] sections are correctly configured:

  • error-on-warning = true enforces strict checking (appropriate for CI).
  • Exclusion list (docs, eval, mlir) matches patterns used by other linters in this config.
.github/workflows/cd.yml (1)

15-15: ✅ Workflow references consistently updated to v1.17.2.

Both packaging workflows (sdist and wheel) are correctly pinned to commit hash ea4fccbb432596cbb6840a9608d6376b6b2c8ff7 with version comment # v1.17.2. This maintains the established pattern of immutable commit references with version comments.

Also applies to: 34-34

.github/workflows/upstream.yml (1)

22-22: ✅ Workflow references consistently updated to v1.17.2.

Both Qiskit upstream testing workflows are correctly updated to v1.17.2 using the immutable commit hash pattern established throughout the codebase.

Also applies to: 31-31

.github/workflows/ci.yml (2)

17-17: ✅ All workflow references consistently updated to v1.17.2.

All 14 reusable workflow references across C++ tests, coverage, linting, and Python tests/packaging jobs have been uniformly updated from v1.17.1 (4845865ca25c2da3374981f47ae9ed9607a30e1c) to v1.17.2 (ea4fccbb432596cbb6840a9608d6376b6b2c8ff7). This maintains immutable pinning and consistency across the CI pipeline.

Also applies to: 33-33, 53-53, 74-74, 98-98, 121-121, 139-139, 149-149, 158-158, 183-183, 191-191, 205-205, 221-221, 239-239


213-215: ✅ Workflow reference updated correctly with supported parameter.

The python-linter job now uses the immutable commit hash ea4fccbb432596cbb6840a9608d6376b6b2c8ff7 (v1.17.2) instead of the previous mutable branch reference, matching all other workflows in the file. The enable-ty: true parameter is properly supported by the reusable workflow at v1.17.2.


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.

Signed-off-by: burgholzer <burgholzer@me.com>
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

📜 Review details

Configuration used: CodeRabbit UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between eccf21f and 0481dbb.

📒 Files selected for processing (1)
  • .github/workflows/ci.yml (1 hunks)

Signed-off-by: burgholzer <burgholzer@me.com>
Signed-off-by: burgholzer <burgholzer@me.com>
Signed-off-by: burgholzer <burgholzer@me.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

code quality Code quality improvements python Anything related to Python code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant