Skip to content

Commit 66ee428

Browse files
authored
Update instruction_name type to Iterable in ContainsInstruction
1 parent 74a9466 commit 66ee428

1 file changed

Lines changed: 8 additions & 8 deletions

File tree

qiskit/transpiler/passes/utils/contains_instruction.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,13 @@
99
# Any modifications or derivative works of this code must retain this
1010
# copyright notice, and modified files need to carry a notice indicating
1111
# that they have been altered from the originals.
12+
"""Check if a property reached a fixed point."""
13+
from collections.abc import Iterable
14+
from typing import TYPE_CHECKING
1215

13-
"""Check if the DAG contains a specific instruction."""
16+
if TYPE_CHECKING:
17+
from qiskit.dagcircuit import DAGCircuit
1418

15-
from __future__ import annotations
16-
17-
from qiskit.dagcircuit import DAGCircuit
1819
from qiskit.transpiler.basepasses import AnalysisPass
1920

2021

@@ -26,9 +27,8 @@ class ContainsInstruction(AnalysisPass):
2627
that instruction and ``False`` if it does not.
2728
"""
2829

29-
def __init__(self, instruction_name: str | set[str], recurse: bool = True) -> None:
30-
"""Initialize a ``ContainsInstruction`` pass.
31-
30+
def __init__(self, instruction_name: str | Iterable[str], recurse: bool = True) -> None:
31+
"""
3232
Args:
3333
instruction_name: The instruction or instructions to check are in
3434
the DAG. The output in the property set is set to ``contains_`` prefixed on each
@@ -42,7 +42,7 @@ def __init__(self, instruction_name: str | set[str], recurse: bool = True) -> No
4242
self._recurse = recurse
4343

4444
def run(self, dag: DAGCircuit) -> None:
45-
"""Run the ContainsInstruction pass on *dag*."""
45+
"""Run the ContainsInstruction pass on ``dag``."""
4646
names = dag.count_ops(recurse=self._recurse)
4747
for name in self._instruction_names:
4848
self.property_set[f"contains_{name}"] = name in names

0 commit comments

Comments
 (0)