From a996b1d5fed9384a5a4fa694ba6f952e101dedde Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Fri, 29 Nov 2024 19:27:18 +0100 Subject: [PATCH] =?UTF-8?q?=E2=AC=86=EF=B8=8F=F0=9F=AA=9D=20Update=20pre-c?= =?UTF-8?q?ommit=20hook=20astral-sh/ruff-pre-commit=20to=20v0.8.1=20(#431)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .pre-commit-config.yaml | 8 ++++---- frontend/src/mqt/bench/viewer/backend.py | 6 +++--- pyproject.toml | 15 ++++++++++++--- .../qiskit_application_optimization/routing.py | 10 +++++----- src/mqt/bench/cli.py | 2 +- src/mqt/bench/devices/ibm.py | 6 +++--- src/mqt/bench/devices/ionq.py | 2 +- src/mqt/bench/devices/iqm.py | 2 +- src/mqt/bench/devices/oqc.py | 2 +- src/mqt/bench/devices/quantinuum.py | 2 +- src/mqt/bench/devices/rigetti.py | 2 +- tests/devices/test_devices.py | 2 +- 12 files changed, 34 insertions(+), 25 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 261f39eb9..4982c6d5d 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -57,7 +57,7 @@ repos: # Python linting and formatting using ruff - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.7.4 + rev: v0.8.1 hooks: - id: ruff args: ["--fix", "--show-fixes"] @@ -72,7 +72,7 @@ repos: # Format configuration files with prettier - repo: https://github.com/rbubley/mirrors-prettier - rev: v3.3.3 + rev: v3.4.1 hooks: - id: prettier types_or: [yaml, markdown, html, css, scss, javascript, json] @@ -98,7 +98,7 @@ repos: # Check for spelling - repo: https://github.com/crate-ci/typos - rev: v1.27.3 + rev: v1.28.1 hooks: - id: typos exclude: legal.html @@ -129,6 +129,6 @@ repos: # Check the pyproject.toml file - repo: https://github.com/henryiii/validate-pyproject-schema-store - rev: 2024.11.11 + rev: 2024.11.25 hooks: - id: validate-pyproject diff --git a/frontend/src/mqt/bench/viewer/backend.py b/frontend/src/mqt/bench/viewer/backend.py index 428222963..cd8805b82 100644 --- a/frontend/src/mqt/bench/viewer/backend.py +++ b/frontend/src/mqt/bench/viewer/backend.py @@ -244,7 +244,7 @@ def filter_database(self, benchmark_config: BenchmarkConfiguration) -> list[str] ] db_filtered = pd.concat([db_filtered, db_tmp6]) - return cast(list[str], db_filtered["filename"].to_list()) + return cast("list[str]", db_filtered["filename"].to_list()) def generate_zip_ephemeral_chunks( self, @@ -567,7 +567,7 @@ def get_opt_level(filename: str) -> int: pat = re.compile(r"opt\d") m = pat.search(filename) num = m.group()[-1:] if m else -1 - return int(cast(str, num)) + return int(cast("str", num)) def get_num_qubits(filename: str) -> int: @@ -582,7 +582,7 @@ def get_num_qubits(filename: str) -> int: pat = re.compile(r"(\d+)\.") m = pat.search(filename) num = m.group()[0:-1] if m else -1 - return int(cast(str, num)) + return int(cast("str", num)) def get_tket_settings(filename: str) -> str | None: diff --git a/pyproject.toml b/pyproject.toml index c918d77b2..a55a4493f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -102,6 +102,7 @@ filterwarnings = [ 'ignore:.*invalid value encountered in det.*:RuntimeWarning:', 'ignore::DeprecationWarning:.*(docplex).*', 'ignore::SyntaxWarning:.*(docplex).*', + # Qiskit 1.2 deprecations 'ignore:.*The abstract Provider and ProviderV1 classes are deprecated.*:DeprecationWarning:qiskit.*', 'ignore:.*qiskit.providers.models is deprecated since Qiskit 1.2*:DeprecationWarning:', 'ignore:.*Treating CircuitInstruction as an iterable is deprecated legacy behavior since Qiskit 1.2*:DeprecationWarning:pytket.*', @@ -110,7 +111,17 @@ filterwarnings = [ 'ignore:.*The class ``qiskit.qobj.pulse_qobj.Pulse.*`` is deprecated as of qiskit 1.2.*:DeprecationWarning:qiskit.*', 'ignore:.*The class ``qiskit.primitives.sampler.Sampler`` is deprecated as of qiskit 1.2*:DeprecationWarning:mqt.*', 'ignore:.*The class ``qiskit.primitives.estimator.Estimator`` is deprecated as of qiskit 1.2*:DeprecationWarning:mqt.*', + # TKET Warnings 'ignore:.*The pytket Circuit contains implicit qubit permutations*.:UserWarning:pytket.extensions.qiskit.qiskit_convert', + # Qiskit 1.3 deprecations + 'ignore:.*The property ``qiskit.dagcircuit.dagcircuit.DAGCircuit.*`` is deprecated as of qiskit 1.3.0.*:DeprecationWarning:qiskit.*', + 'ignore:.*The class ``qiskit.pulse.*`` is deprecated as of Qiskit 1.3.*:DeprecationWarning:qiskit.*', + 'ignore:.*The class ``qiskit.qobj.*`` is deprecated as of Qiskit 1.3.*:DeprecationWarning:qiskit.*', + 'ignore:.*The property ``qiskit.transpiler.target.*`` is deprecated as of Qiskit 1.3.*:DeprecationWarning:qiskit.*', + 'ignore:.*The property ``qiskit.circuit.instruction.Instruction.condition`` is deprecated as of qiskit 1.3.0.*:DeprecationWarning:', + # Warnings that should be fixed by us in a subsequent PR. Most likely as part of https://github.com/cda-tum/mqt-bench/pull/429 + 'ignore:.*Providing non-standard gates.*is deprecated for both ``transpile`` and ``generate_preset_pass_manager`` as of Qiskit 1.3.0.*:DeprecationWarning:qiskit.*', + 'ignore:.*is pending deprecation as of qiskit 1.3..*:PendingDeprecationWarning:', ] [tool.coverage] @@ -184,15 +195,13 @@ extend-select = [ "SLF", # flake8-self "SLOT", # flake8-slots "SIM", # flake8-simplify - "TCH", # flake8-type-checking + "TC", # flake8-type-checking "TID", # flake8-tidy-imports "TRY", # tryceratops "UP", # pyupgrade "YTT", # flake8-2020 ] ignore = [ - "ANN101", # Missing type annotation for self in method - "ANN102", # Missing type annotation for cls in classmethod "ISC001", # Conflicts with formatter "E501", # Line too long (Black is enough) "PLR", # Design related pylint codes diff --git a/src/mqt/bench/benchmarks/qiskit_application_optimization/routing.py b/src/mqt/bench/benchmarks/qiskit_application_optimization/routing.py index 230b4e0e5..c025ca47f 100644 --- a/src/mqt/bench/benchmarks/qiskit_application_optimization/routing.py +++ b/src/mqt/bench/benchmarks/qiskit_application_optimization/routing.py @@ -10,11 +10,11 @@ from qiskit_algorithms.minimum_eigensolvers import VQE from qiskit_algorithms.optimizers import SLSQP from qiskit_optimization import QuadraticProgram -from qiskit_optimization.problems import LinearExpression, QuadraticExpression if TYPE_CHECKING: # pragma: no cover from numpy.typing import NDArray from qiskit import QuantumCircuit + from qiskit_optimization.problems import LinearExpression, QuadraticExpression class Initializer: @@ -106,7 +106,7 @@ def binary_representation( # Evaluates the cost distance from a binary representation of a path def fun(x: NDArray[np.float64]) -> float: return cast( - float, + "float", np.dot(np.around(x), np.dot(q, np.around(x))) + np.dot(g, np.around(x)) + c, ) @@ -114,7 +114,7 @@ def fun(x: NDArray[np.float64]) -> float: except Exception: cost = 0 - return q, g, cast(float, c), cost + return q, g, cast("float", c), cost def construct_problem(self, q: QuadraticExpression, g: LinearExpression, c: float) -> QuadraticProgram: """Constructs the problem.""" @@ -155,8 +155,8 @@ def create_circuit(num_nodes: int = 3, num_vehs: int = 2) -> QuantumCircuit: quantum_optimizer = QuantumOptimizer(instance, n, k) q, g, c, _binary_cost = quantum_optimizer.binary_representation(x_sol=np.array(0.0, dtype=float)) - q_casted = cast(QuadraticExpression, q) - g_casted = cast(LinearExpression, g) + q_casted = cast("QuadraticExpression", q) + g_casted = cast("LinearExpression", g) qp = quantum_optimizer.construct_problem(q_casted, g_casted, c) # Instantiate the quantum optimizer class with parameters: qc = quantum_optimizer.solve_problem(qp) diff --git a/src/mqt/bench/cli.py b/src/mqt/bench/cli.py index 289e0de97..c59f3b6a9 100644 --- a/src/mqt/bench/cli.py +++ b/src/mqt/bench/cli.py @@ -89,6 +89,6 @@ def parse_benchmark_name_and_instance(algorithm: str) -> tuple[str, str | None]: if algorithm.startswith(("shor_", "groundstate_")): as_list = algorithm.split("_", 2) assert len(as_list) == 2 - return cast(tuple[str, str], tuple(as_list)) + return cast("tuple[str, str]", tuple(as_list)) return algorithm, None diff --git a/src/mqt/bench/devices/ibm.py b/src/mqt/bench/devices/ibm.py index 6b2f0a645..9063f399a 100644 --- a/src/mqt/bench/devices/ibm.py +++ b/src/mqt/bench/devices/ibm.py @@ -66,7 +66,7 @@ def import_backend(cls, path: Path) -> Device: Returns: the Device object """ with path.open() as json_file: - ibm_calibration = cast(IBMCalibration, json.load(json_file)) + ibm_calibration = cast("IBMCalibration", json.load(json_file)) device = Device() device.name = ibm_calibration["name"] @@ -116,8 +116,8 @@ def __import_target(cls, target: Target) -> DeviceCalibration: for qubit in range(num_qubits): qubit_props = target.qubit_properties[qubit] - calibration.t1[qubit] = cast(float, qubit_props.t1) - calibration.t2[qubit] = cast(float, qubit_props.t2) + calibration.t1[qubit] = cast("float", qubit_props.t1) + calibration.t2[qubit] = cast("float", qubit_props.t2) calibration.single_qubit_gate_fidelity = {qubit: {} for qubit in range(num_qubits)} calibration.single_qubit_gate_duration = {qubit: {} for qubit in range(num_qubits)} diff --git a/src/mqt/bench/devices/ionq.py b/src/mqt/bench/devices/ionq.py index a32b7b054..e586202f4 100644 --- a/src/mqt/bench/devices/ionq.py +++ b/src/mqt/bench/devices/ionq.py @@ -60,7 +60,7 @@ def import_backend(cls, path: Path) -> Device: the Device object """ with path.open() as json_file: - ionq_calibration = cast(IonQCalibration, json.load(json_file)) + ionq_calibration = cast("IonQCalibration", json.load(json_file)) device = Device() device.name = ionq_calibration["name"] diff --git a/src/mqt/bench/devices/iqm.py b/src/mqt/bench/devices/iqm.py index edfdfd6c1..afaf21a48 100644 --- a/src/mqt/bench/devices/iqm.py +++ b/src/mqt/bench/devices/iqm.py @@ -70,7 +70,7 @@ def import_backend(cls, path: Path) -> Device: Returns: the Device object """ with path.open() as json_file: - iqm_calibration = cast(IQMCalibration, json.load(json_file)) + iqm_calibration = cast("IQMCalibration", json.load(json_file)) device = Device() device.name = iqm_calibration["name"] diff --git a/src/mqt/bench/devices/oqc.py b/src/mqt/bench/devices/oqc.py index 8b2d3954a..14cf54711 100644 --- a/src/mqt/bench/devices/oqc.py +++ b/src/mqt/bench/devices/oqc.py @@ -80,7 +80,7 @@ def import_backend(cls, path: Path) -> Device: the Device object """ with path.open() as json_file: - oqc_calibration = cast(OQCCalibration, json.load(json_file)) + oqc_calibration = cast("OQCCalibration", json.load(json_file)) device = Device() device.name = oqc_calibration["name"] diff --git a/src/mqt/bench/devices/quantinuum.py b/src/mqt/bench/devices/quantinuum.py index aaa088075..1fcc2d7dd 100644 --- a/src/mqt/bench/devices/quantinuum.py +++ b/src/mqt/bench/devices/quantinuum.py @@ -58,7 +58,7 @@ def import_backend(cls, path: Path) -> Device: the Device object """ with path.open() as json_file: - quantinuum_calibration = cast(QuantinuumCalibration, json.load(json_file)) + quantinuum_calibration = cast("QuantinuumCalibration", json.load(json_file)) device = Device() device.name = quantinuum_calibration["name"] diff --git a/src/mqt/bench/devices/rigetti.py b/src/mqt/bench/devices/rigetti.py index e43d9a8b8..bad9dcdb9 100644 --- a/src/mqt/bench/devices/rigetti.py +++ b/src/mqt/bench/devices/rigetti.py @@ -124,7 +124,7 @@ def import_backend(cls, path: Path) -> Device: the Device object """ with path.open() as json_file: - rigetti_calibration = cast(RigettiCalibration, json.load(json_file)) + rigetti_calibration = cast("RigettiCalibration", json.load(json_file)) device = Device() device.name = rigetti_calibration["name"] diff --git a/tests/devices/test_devices.py b/tests/devices/test_devices.py index 4357531e7..647ff3197 100644 --- a/tests/devices/test_devices.py +++ b/tests/devices/test_devices.py @@ -17,7 +17,7 @@ @pytest.mark.parametrize( - "device", get_available_devices(sanitize_device=True), ids=lambda device: cast(str, device.name) + "device", get_available_devices(sanitize_device=True), ids=lambda device: cast("str", device.name) ) def test_sanitized_devices(device: Device) -> None: """Test that all devices can be sanitized and provide complete fidelity data."""