diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index 6ecf084c..e121f1b3 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -10,7 +10,7 @@ on: jobs: build-sdist: name: 🐍 Packaging - uses: munich-quantum-toolkit/workflows/.github/workflows/reusable-python-packaging-sdist.yml@89734354f64f30a80dd16602d4e271df34348987 # v1.17.4 + uses: munich-quantum-toolkit/workflows/.github/workflows/reusable-python-packaging-sdist.yml@d6314c45667c131055a0389afc110e8dedc6da3f # v1.17.11 # Builds wheels on all supported platforms using cibuildwheel. # The wheels are uploaded as GitHub artifacts `dev-cibw-*` or `cibw-*`, depending on whether @@ -29,7 +29,7 @@ jobs: windows-2022, windows-11-arm, ] - uses: munich-quantum-toolkit/workflows/.github/workflows/reusable-python-packaging-wheel-cibuildwheel.yml@89734354f64f30a80dd16602d4e271df34348987 # v1.17.4 + uses: munich-quantum-toolkit/workflows/.github/workflows/reusable-python-packaging-wheel-cibuildwheel.yml@d6314c45667c131055a0389afc110e8dedc6da3f # v1.17.11 with: runs-on: ${{ matrix.runs-on }} diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 15e16567..21c24063 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -16,7 +16,7 @@ concurrency: jobs: change-detection: name: 🔍 Change - uses: munich-quantum-toolkit/workflows/.github/workflows/reusable-change-detection.yml@89734354f64f30a80dd16602d4e271df34348987 # v1.17.4 + uses: munich-quantum-toolkit/workflows/.github/workflows/reusable-change-detection.yml@d6314c45667c131055a0389afc110e8dedc6da3f # v1.17.11 cpp-tests-ubuntu: name: 🇨‌ Test 🐧 @@ -32,7 +32,7 @@ jobs: - runs-on: ubuntu-24.04 compiler: gcc config: Debug - uses: munich-quantum-toolkit/workflows/.github/workflows/reusable-cpp-tests-ubuntu.yml@89734354f64f30a80dd16602d4e271df34348987 # v1.17.4 + uses: munich-quantum-toolkit/workflows/.github/workflows/reusable-cpp-tests-ubuntu.yml@d6314c45667c131055a0389afc110e8dedc6da3f # v1.17.11 with: runs-on: ${{ matrix.runs-on }} compiler: ${{ matrix.compiler }} @@ -52,7 +52,7 @@ jobs: - runs-on: macos-14 compiler: clang config: Debug - uses: munich-quantum-toolkit/workflows/.github/workflows/reusable-cpp-tests-macos.yml@89734354f64f30a80dd16602d4e271df34348987 # v1.17.4 + uses: munich-quantum-toolkit/workflows/.github/workflows/reusable-cpp-tests-macos.yml@d6314c45667c131055a0389afc110e8dedc6da3f # v1.17.11 with: runs-on: ${{ matrix.runs-on }} compiler: ${{ matrix.compiler }} @@ -72,7 +72,7 @@ jobs: - runs-on: windows-2022 compiler: msvc config: Debug - uses: munich-quantum-toolkit/workflows/.github/workflows/reusable-cpp-tests-windows.yml@89734354f64f30a80dd16602d4e271df34348987 # v1.17.4 + uses: munich-quantum-toolkit/workflows/.github/workflows/reusable-cpp-tests-windows.yml@d6314c45667c131055a0389afc110e8dedc6da3f # v1.17.11 with: runs-on: ${{ matrix.runs-on }} compiler: ${{ matrix.compiler }} @@ -82,7 +82,7 @@ jobs: name: 🇨‌ Lint needs: change-detection if: fromJSON(needs.change-detection.outputs.run-cpp-linter) - uses: munich-quantum-toolkit/workflows/.github/workflows/reusable-cpp-linter.yml@89734354f64f30a80dd16602d4e271df34348987 # v1.17.4 + uses: munich-quantum-toolkit/workflows/.github/workflows/reusable-cpp-linter.yml@d6314c45667c131055a0389afc110e8dedc6da3f # v1.17.11 with: build-project: true clang-version: 20 @@ -107,7 +107,7 @@ jobs: macos-14, windows-2022, ] - uses: munich-quantum-toolkit/workflows/.github/workflows/reusable-python-tests.yml@89734354f64f30a80dd16602d4e271df34348987 # v1.17.4 + uses: munich-quantum-toolkit/workflows/.github/workflows/reusable-python-tests.yml@d6314c45667c131055a0389afc110e8dedc6da3f # v1.17.11 with: runs-on: ${{ matrix.runs-on }} @@ -115,7 +115,7 @@ jobs: name: 🐍 Coverage needs: [change-detection, python-tests] if: fromJSON(needs.change-detection.outputs.run-python-tests) - uses: munich-quantum-toolkit/workflows/.github/workflows/reusable-python-coverage.yml@89734354f64f30a80dd16602d4e271df34348987 # v1.17.4 + uses: munich-quantum-toolkit/workflows/.github/workflows/reusable-python-coverage.yml@d6314c45667c131055a0389afc110e8dedc6da3f # v1.17.11 permissions: contents: read id-token: write @@ -124,13 +124,13 @@ jobs: name: 🐍 Lint needs: change-detection if: fromJSON(needs.change-detection.outputs.run-python-tests) - uses: munich-quantum-toolkit/workflows/.github/workflows/reusable-python-linter.yml@89734354f64f30a80dd16602d4e271df34348987 # v1.17.4 + uses: munich-quantum-toolkit/workflows/.github/workflows/reusable-python-linter.yml@d6314c45667c131055a0389afc110e8dedc6da3f # v1.17.11 build-sdist: name: 🚀 CD needs: change-detection if: fromJSON(needs.change-detection.outputs.run-cd) - uses: munich-quantum-toolkit/workflows/.github/workflows/reusable-python-packaging-sdist.yml@89734354f64f30a80dd16602d4e271df34348987 # v1.17.4 + uses: munich-quantum-toolkit/workflows/.github/workflows/reusable-python-packaging-sdist.yml@d6314c45667c131055a0389afc110e8dedc6da3f # v1.17.11 build-wheel: name: 🚀 CD @@ -148,7 +148,7 @@ jobs: windows-2022, windows-11-arm, ] - uses: munich-quantum-toolkit/workflows/.github/workflows/reusable-python-packaging-wheel-cibuildwheel.yml@89734354f64f30a80dd16602d4e271df34348987 # v1.17.4 + uses: munich-quantum-toolkit/workflows/.github/workflows/reusable-python-packaging-wheel-cibuildwheel.yml@d6314c45667c131055a0389afc110e8dedc6da3f # v1.17.11 with: runs-on: ${{ matrix.runs-on }} diff --git a/.github/workflows/update-mqt-core.yml b/.github/workflows/update-mqt-core.yml index 7b592cf9..b5c3baa1 100644 --- a/.github/workflows/update-mqt-core.yml +++ b/.github/workflows/update-mqt-core.yml @@ -21,7 +21,7 @@ concurrency: jobs: update-mqt-core: name: ⬆️ Update MQT Core - uses: munich-quantum-toolkit/workflows/.github/workflows/reusable-mqt-core-update.yml@89734354f64f30a80dd16602d4e271df34348987 # v1.17.4 + uses: munich-quantum-toolkit/workflows/.github/workflows/reusable-mqt-core-update.yml@d6314c45667c131055a0389afc110e8dedc6da3f # v1.17.11 with: update-to-head: ${{ github.event.inputs.update-to-head == 'true' }} secrets: diff --git a/.github/workflows/upstream.yml b/.github/workflows/upstream.yml index 8f20e574..a32e1908 100644 --- a/.github/workflows/upstream.yml +++ b/.github/workflows/upstream.yml @@ -19,7 +19,7 @@ jobs: fail-fast: false matrix: runs-on: [ubuntu-24.04, macos-14, windows-2022] - uses: munich-quantum-toolkit/workflows/.github/workflows/reusable-qiskit-upstream-tests.yml@89734354f64f30a80dd16602d4e271df34348987 # v1.17.4 + uses: munich-quantum-toolkit/workflows/.github/workflows/reusable-qiskit-upstream-tests.yml@d6314c45667c131055a0389afc110e8dedc6da3f # v1.17.11 with: runs-on: ${{ matrix.runs-on }} setup-z3: true @@ -28,7 +28,7 @@ jobs: name: Create issue on failure needs: qiskit-upstream-tests if: ${{ always() }} - uses: munich-quantum-toolkit/workflows/.github/workflows/reusable-qiskit-upstream-issue.yml@89734354f64f30a80dd16602d4e271df34348987 # v1.17.4 + uses: munich-quantum-toolkit/workflows/.github/workflows/reusable-qiskit-upstream-issue.yml@d6314c45667c131055a0389afc110e8dedc6da3f # v1.17.11 with: tests-result: ${{ needs.qiskit-upstream-tests.result }} permissions: diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index b7e8d955..31c343fa 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -60,20 +60,20 @@ repos: # Ensure uv lock file is up-to-date - repo: https://github.com/astral-sh/uv-pre-commit - rev: 0.9.17 + rev: 0.9.22 hooks: - id: uv-lock # Python linting using ruff - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.14.9 + rev: v0.14.10 hooks: - id: ruff-check - id: ruff-format # Static type checking using mypy - repo: https://github.com/pre-commit/mirrors-mypy - rev: v1.19.0 + rev: v1.19.1 hooks: - id: mypy files: ^(python/mqt|test/python|noxfile.py) @@ -98,7 +98,7 @@ repos: # Clang-format the C++ part of the code base automatically - repo: https://github.com/pre-commit/mirrors-clang-format - rev: v21.1.7 + rev: v21.1.8 hooks: - id: clang-format types_or: [c++, c, cuda] @@ -151,7 +151,7 @@ repos: # Check the pyproject.toml file - repo: https://github.com/henryiii/validate-pyproject-schema-store - rev: 2026.01.02 + rev: 2026.01.08 hooks: - id: validate-pyproject diff --git a/python/mqt/debugger/check/run_preparation.py b/python/mqt/debugger/check/run_preparation.py index fae64e34..f9a1de8b 100644 --- a/python/mqt/debugger/check/run_preparation.py +++ b/python/mqt/debugger/check/run_preparation.py @@ -185,8 +185,6 @@ def estimate_required_shots_from_path( Returns: int: The estimated number of shots required for the program. """ - if isinstance(compiled_program, str): - compiled_program = Path(compiled_program) - with compiled_program.open("r") as f: - program = f.read() - return estimate_required_shots(program, calibration, p_value, num_trials, accuracy) + compiled_program = Path(compiled_program) + program = compiled_program.read_text() + return estimate_required_shots(program, calibration, p_value, num_trials, accuracy) diff --git a/python/mqt/debugger/dap/messages/launch_dap_message.py b/python/mqt/debugger/dap/messages/launch_dap_message.py index 65aabd19..42c00184 100644 --- a/python/mqt/debugger/dap/messages/launch_dap_message.py +++ b/python/mqt/debugger/dap/messages/launch_dap_message.py @@ -63,19 +63,18 @@ def handle(self, server: DAPServer) -> dict[str, Any]: dict[str, Any]: The response to the request. """ program_path = Path(self.program) - with program_path.open("r", encoding=locale.getpreferredencoding(False)) as f: - code = f.read() - server.source_code = code - try: - server.simulation_state.load_code(code) - except RuntimeError: - return { - "type": "response", - "request_seq": self.sequence_number, - "success": False, - "command": "launch", - "message": "An error occurred while parsing the code.", - } + code = program_path.read_text(encoding=locale.getpreferredencoding(False)) + server.source_code = code + try: + server.simulation_state.load_code(code) + except RuntimeError: + return { + "type": "response", + "request_seq": self.sequence_number, + "success": False, + "command": "launch", + "message": "An error occurred while parsing the code.", + } if not self.stop_on_entry: server.simulation_state.run_simulation() server.source_file = {"name": program_path.name, "path": self.program} diff --git a/python/mqt/debugger/dap/messages/restart_dap_message.py b/python/mqt/debugger/dap/messages/restart_dap_message.py index b455b2e1..a3d8bdca 100644 --- a/python/mqt/debugger/dap/messages/restart_dap_message.py +++ b/python/mqt/debugger/dap/messages/restart_dap_message.py @@ -64,10 +64,9 @@ def handle(self, server: DAPServer) -> dict[str, Any]: """ server.simulation_state.reset_simulation() program_path = Path(self.program) - with program_path.open("r", encoding=locale.getpreferredencoding(False)) as f: - code = f.read() - server.source_code = code - server.simulation_state.load_code(code) + code = program_path.read_text(encoding=locale.getpreferredencoding(False)) + server.source_code = code + server.simulation_state.load_code(code) if not self.stop_on_entry: server.simulation_state.run_simulation() server.source_file = {"name": program_path.name, "path": self.program} diff --git a/test/python/test_diagnosis.py b/test/python/test_diagnosis.py index 398f86b9..dc5fc5f2 100644 --- a/test/python/test_diagnosis.py +++ b/test/python/test_diagnosis.py @@ -34,8 +34,8 @@ def load_instance(name: str) -> SimulationState: SimulationState: The generated simulation state. """ state = create_ddsim_simulation_state() - with Path(f"test/python/resources/diagnosis/{name}.qasm").open(encoding=locale.getpreferredencoding(False)) as f: - state.load_code(f.read()) + code = Path(f"test/python/resources/diagnosis/{name}.qasm").read_text(encoding=locale.getpreferredencoding(False)) + state.load_code(code) return state diff --git a/test/python/test_end_to_end.py b/test/python/test_end_to_end.py index ab58951a..f7a05df4 100644 --- a/test/python/test_end_to_end.py +++ b/test/python/test_end_to_end.py @@ -84,10 +84,10 @@ def load_instance(name: str) -> tuple[SimulationState, ExpectedSolution]: tuple[SimulationState, ExpectedSolution]: The simulation state and the expected solution. """ state = create_ddsim_simulation_state() - with Path(f"test/python/resources/end-to-end/{name}.qasm").open(encoding=locale.getpreferredencoding(False)) as f: - state.load_code(f.read()) - with Path(f"test/python/resources/end-to-end/{name}.out").open(encoding=locale.getpreferredencoding(False)) as f: - solution = parse_solution(f.read()) + code = Path(f"test/python/resources/end-to-end/{name}.qasm").read_text(encoding=locale.getpreferredencoding(False)) + state.load_code(code) + text = Path(f"test/python/resources/end-to-end/{name}.out").read_text(encoding=locale.getpreferredencoding(False)) + solution = parse_solution(text) return (state, solution) diff --git a/test/python/test_python_bindings.py b/test/python/test_python_bindings.py index 4424b2f8..00f5d50d 100644 --- a/test/python/test_python_bindings.py +++ b/test/python/test_python_bindings.py @@ -32,11 +32,10 @@ def simulation_instance_ghz() -> Generator[SimulationInstance, None, None]: """Fixture for the GHZ state simulation instance.""" simulation_state = mqt.debugger.create_ddsim_simulation_state() - with Path("test/python/resources/bindings/ghz-incorrect.qasm").open( + code = Path("test/python/resources/bindings/ghz-incorrect.qasm").read_text( encoding=locale.getpreferredencoding(False) - ) as f: - code = f.read() - simulation_state.load_code(code) + ) + simulation_state.load_code(code) yield (simulation_state, 0) mqt.debugger.destroy_ddsim_simulation_state(simulation_state) @@ -45,9 +44,8 @@ def simulation_instance_ghz() -> Generator[SimulationInstance, None, None]: def simulation_instance_jumps() -> Generator[SimulationInstance, None, None]: """Fixture for the Jumps simulation instance.""" simulation_state = mqt.debugger.create_ddsim_simulation_state() - with Path("test/python/resources/bindings/jumps.qasm").open(encoding=locale.getpreferredencoding(False)) as f: - code = f.read() - simulation_state.load_code(code) + code = Path("test/python/resources/bindings/jumps.qasm").read_text(encoding=locale.getpreferredencoding(False)) + simulation_state.load_code(code) yield (simulation_state, 1) mqt.debugger.destroy_ddsim_simulation_state(simulation_state) @@ -56,9 +54,8 @@ def simulation_instance_jumps() -> Generator[SimulationInstance, None, None]: def simulation_instance_classical() -> Generator[SimulationInstance, None, None]: """Fixture for the Classical simulation instance.""" simulation_state = mqt.debugger.create_ddsim_simulation_state() - with Path("test/python/resources/bindings/classical.qasm").open(encoding=locale.getpreferredencoding(False)) as f: - code = f.read() - simulation_state.load_code(code) + code = Path("test/python/resources/bindings/classical.qasm").read_text(encoding=locale.getpreferredencoding(False)) + simulation_state.load_code(code) yield (simulation_state, 2) mqt.debugger.destroy_ddsim_simulation_state(simulation_state)