From 8d5d509ec3418891298dfdd5fe27387140028265 Mon Sep 17 00:00:00 2001 From: Ara Ghukasyan Date: Tue, 12 Sep 2023 14:32:31 -0400 Subject: [PATCH] type hint fixes for QiskitExecutor --- .../quantum_plugins/qiskit_plugin/qiskit_plugin.py | 8 ++++---- .../quantum_plugins/qiskit_plugin/qiskit_utils.py | 3 +++ 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/covalent/executor/quantum_plugins/qiskit_plugin/qiskit_plugin.py b/covalent/executor/quantum_plugins/qiskit_plugin/qiskit_plugin.py index a8d098b3e..47e62a781 100644 --- a/covalent/executor/quantum_plugins/qiskit_plugin/qiskit_plugin.py +++ b/covalent/executor/quantum_plugins/qiskit_plugin/qiskit_plugin.py @@ -20,7 +20,7 @@ import asyncio import time -from typing import Sequence, Union +from typing import Optional, Sequence, Union import pennylane as qml from local_sampler import QiskitLocalSampler @@ -190,14 +190,14 @@ class QiskitExecutor(AsyncBaseQExecutor): single_job: bool = False local_transpile: bool = False - max_time: Union[int, str] = None + max_time: Optional[Union[int, str]] = None - ibmqx_url: str = None + ibmqx_url: Optional[str] = None channel: str = "ibm_quantum" instance: str = "" cloud_instance: str = "" - options: dict = Field( + options: Optional[Union[dict, tuple]] = Field( # pylint: disable=unnecessary-lambda default_factory=lambda: get_config("qelectron")["QiskitExecutor"]["options"] ) diff --git a/covalent/executor/quantum_plugins/qiskit_plugin/qiskit_utils.py b/covalent/executor/quantum_plugins/qiskit_plugin/qiskit_utils.py index 0171cec1a..41228b774 100644 --- a/covalent/executor/quantum_plugins/qiskit_plugin/qiskit_utils.py +++ b/covalent/executor/quantum_plugins/qiskit_plugin/qiskit_utils.py @@ -29,6 +29,9 @@ def extract_options(opts: dict) -> Options: """ Construct a Qiskit `Options` object from the options dictionary """ + if isinstance(opts, tuple): + opts = dict(opts) + _options = Options() _options.optimization_level = opts.get("optimization_level", 3) _options.resilience_level = opts.get("resilience_level", 1)