Skip to content

Commit 768154b

Browse files
authored
🏷️ providing a convenient CircuitInputType (cda-tum#661)
## Description This PR provides a convenient type that summarizes the default circuit inputs to the `load` method. Special care is taken that this type is only defined in type checking environments and does not require importing optional dependencies that might not be available at runtime (such as qiskit). ## Checklist: <!--- This checklist serves as a reminder of a couple of things that ensure your pull request will be merged swiftly. --> - [x] The pull request only contains commits that are related to it. - [x] I have added appropriate tests and documentation. - [x] I have made sure that all CI jobs on GitHub pass. - [x] The pull request introduces no new warnings and follows the project's style guidelines. Signed-off-by: burgholzer <burgholzer@me.com>
1 parent 4363502 commit 768154b

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/mqt/core/load.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,17 @@
44

55
from os import PathLike
66
from pathlib import Path
7-
from typing import TYPE_CHECKING
7+
from typing import TYPE_CHECKING, Union
88

99
from . import QuantumComputation
1010

1111
if TYPE_CHECKING:
1212
from qiskit.circuit import QuantumCircuit
1313

14+
CircuitInputType = Union[QuantumComputation, str, PathLike[str], QuantumCircuit]
1415

15-
def load(input_circuit: QuantumComputation | str | PathLike[str] | QuantumCircuit) -> QuantumComputation:
16+
17+
def load(input_circuit: CircuitInputType) -> QuantumComputation:
1618
"""Load a quantum circuit from any supported format as a :class:`~mqt.core.QuantumComputation`.
1719
1820
Args:
@@ -48,3 +50,5 @@ def load(input_circuit: QuantumComputation | str | PathLike[str] | QuantumCircui
4850

4951

5052
__all__ = ["load"]
53+
if TYPE_CHECKING:
54+
__all__ += ["CircuitInputType"]

0 commit comments

Comments
 (0)