Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix transpiler mypy errors #11468

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open

Fix transpiler mypy errors #11468

wants to merge 5 commits into from

Conversation

Randl
Copy link
Contributor

@Randl Randl commented Dec 31, 2023

Summary

Fixing mypy errors for transpiler module. Followup to #8266
See also #6905

Details and comments

diff of mypy output before and after PR
35c35
< qiskit/transpiler/synthesis/aqc/fast_gradient/fast_grad_utils.py:32: error: Incompatible return value type (got "Literal[False] | Any | bool_", expected "bool")  [return-value]
---
> qiskit/transpiler/synthesis/aqc/fast_gradient/fast_grad_utils.py:31: error: Incompatible return value type (got "Literal[False] | Any | bool_", expected "bool")  [return-value]
237d236
< qiskit/circuit/quantumcircuit.py:1979: error: Argument 1 to "Decompose" has incompatible type "type[Gate] | Sequence[type[Gate]] | Sequence[str] | str | None"; expected "type[Gate] | list[type[Gate]] | list[str] | str | None"  [arg-type]
643d641
< qiskit/transpiler/passes/layout/vf2_utils.py:55: error: Need type annotation for "weights"  [var-annotated]
1081,1097c1079,1099
< qiskit/transpiler/instruction_durations.py:80: error: "Backend" has no attribute "properties"  [attr-defined]
< qiskit/transpiler/instruction_durations.py:87: error: "Backend" has no attribute "properties"  [attr-defined]
< qiskit/transpiler/instruction_durations.py:93: error: "Backend" has no attribute "configuration"  [attr-defined]
< qiskit/transpiler/instruction_durations.py:130: error: Incompatible types in assignment (expression has type "tuple[float | str | Iterable[int] | Iterable[float], float | str | Iterable[int] | Iterable[float], float | str | Iterable[int] | Iterable[float], None, float | str | Iterable[int] | Iterable[float]]", target has type "tuple[str, Iterable[int] | None, float, Iterable[float] | None, str]")  [assignment]
< qiskit/transpiler/instruction_durations.py:130: error: Incompatible types in assignment (expression has type "tuple[float | str | Iterable[int] | Iterable[float], float | str | Iterable[int] | Iterable[float], float | str | Iterable[int] | Iterable[float], None, float | str | Iterable[int] | Iterable[float]]", target has type "tuple[str, Iterable[int] | None, float, Iterable[float] | None]")  [assignment]
< qiskit/transpiler/instruction_durations.py:130: error: Incompatible types in assignment (expression has type "tuple[float | str | Iterable[int] | Iterable[float], float | str | Iterable[int] | Iterable[float], float | str | Iterable[int] | Iterable[float], None, float | str | Iterable[int] | Iterable[float]]", target has type "tuple[str, Iterable[int] | None, float, str]")  [assignment]
< qiskit/transpiler/instruction_durations.py:130: error: Incompatible types in assignment (expression has type "tuple[float | str | Iterable[int] | Iterable[float], float | str | Iterable[int] | Iterable[float], float | str | Iterable[int] | Iterable[float], None, float | str | Iterable[int] | Iterable[float]]", target has type "tuple[str, Iterable[int] | None, float]")  [assignment]
< qiskit/transpiler/instruction_durations.py:132: error: Incompatible types in assignment (expression has type "tuple[float | str | Iterable[int] | Iterable[float], ...]", target has type "tuple[str, Iterable[int] | None, float, Iterable[float] | None, str]")  [assignment]
< qiskit/transpiler/instruction_durations.py:132: error: Incompatible types in assignment (expression has type "tuple[float | str | Iterable[int] | Iterable[float], ...]", target has type "tuple[str, Iterable[int] | None, float, Iterable[float] | None]")  [assignment]
< qiskit/transpiler/instruction_durations.py:132: error: Incompatible types in assignment (expression has type "tuple[float | str | Iterable[int] | Iterable[float], ...]", target has type "tuple[str, Iterable[int] | None, float, str]")  [assignment]
< qiskit/transpiler/instruction_durations.py:132: error: Incompatible types in assignment (expression has type "tuple[float | str | Iterable[int] | Iterable[float], ...]", target has type "tuple[str, Iterable[int] | None, float]")  [assignment]
< qiskit/transpiler/instruction_durations.py:148: error: Need more than 4 values to unpack (5 expected)  [misc]
< qiskit/transpiler/instruction_durations.py:148: error: Need more than 3 values to unpack (5 expected)  [misc]
< qiskit/transpiler/instruction_durations.py:222: error: Incompatible types in assignment (expression has type "tuple[str, tuple[int, ...]]", variable has type "tuple[str, tuple[int, ...], tuple[float, ...]]")  [assignment]
< qiskit/transpiler/instruction_durations.py:227: error: Invalid index type "tuple[str, tuple[int, ...], tuple[float, ...]]" for "dict[tuple[str, tuple[int, ...]], tuple[float, str]]"; expected type "tuple[str, tuple[int, ...]]"  [index]
< qiskit/transpiler/instruction_durations.py:237: error: Incompatible types in assignment (expression has type "float | ParameterExpression", variable has type "float")  [assignment]
< qiskit/transpiler/passes/optimization/template_matching/forward_match.py:155: error: Need type annotation for "block" (hint: "block: List[<type>] = ...")  [var-annotated]
---
> qiskit/transpiler/instruction_durations.py:83: error: "Backend" has no attribute "properties"  [attr-defined]
> qiskit/transpiler/instruction_durations.py:90: error: "Backend" has no attribute "properties"  [attr-defined]
> qiskit/transpiler/instruction_durations.py:96: error: "Backend" has no attribute "configuration"  [attr-defined]
> qiskit/transpiler/instruction_durations.py:133: error: Incompatible types in assignment (expression has type "tuple[float | str | Iterable[int] | Iterable[float], float | str | Iterable[int] | Iterable[float], float | str | Iterable[int] | Iterable[float], None, float | str | Iterable[int] | Iterable[float]]", target has type "tuple[str, Iterable[int] | None, float, Iterable[float] | None, str]")  [assignment]
> qiskit/transpiler/instruction_durations.py:133: error: Incompatible types in assignment (expression has type "tuple[float | str | Iterable[int] | Iterable[float], float | str | Iterable[int] | Iterable[float], float | str | Iterable[int] | Iterable[float], None, float | str | Iterable[int] | Iterable[float]]", target has type "tuple[str, Iterable[int] | None, float, Iterable[float] | None]")  [assignment]
> qiskit/transpiler/instruction_durations.py:133: error: Incompatible types in assignment (expression has type "tuple[float | str | Iterable[int] | Iterable[float], float | str | Iterable[int] | Iterable[float], float | str | Iterable[int] | Iterable[float], None, float | str | Iterable[int] | Iterable[float]]", target has type "tuple[str, Iterable[int] | None, float, str]")  [assignment]
> qiskit/transpiler/instruction_durations.py:133: error: Incompatible types in assignment (expression has type "tuple[float | str | Iterable[int] | Iterable[float], float | str | Iterable[int] | Iterable[float], float | str | Iterable[int] | Iterable[float], None, float | str | Iterable[int] | Iterable[float]]", target has type "tuple[str, Iterable[int] | None, float]")  [assignment]
> qiskit/transpiler/instruction_durations.py:135: error: Incompatible types in assignment (expression has type "tuple[float | str | Iterable[int] | Iterable[float], ...]", target has type "tuple[str, Iterable[int] | None, float, Iterable[float] | None, str]")  [assignment]
> qiskit/transpiler/instruction_durations.py:135: error: Incompatible types in assignment (expression has type "tuple[float | str | Iterable[int] | Iterable[float], ...]", target has type "tuple[str, Iterable[int] | None, float, Iterable[float] | None]")  [assignment]
> qiskit/transpiler/instruction_durations.py:135: error: Incompatible types in assignment (expression has type "tuple[float | str | Iterable[int] | Iterable[float], ...]", target has type "tuple[str, Iterable[int] | None, float, str]")  [assignment]
> qiskit/transpiler/instruction_durations.py:135: error: Incompatible types in assignment (expression has type "tuple[float | str | Iterable[int] | Iterable[float], ...]", target has type "tuple[str, Iterable[int] | None, float]")  [assignment]
> qiskit/transpiler/instruction_durations.py:151: error: Need more than 4 values to unpack (5 expected)  [misc]
> qiskit/transpiler/instruction_durations.py:151: error: Need more than 3 values to unpack (5 expected)  [misc]
> qiskit/transpiler/instruction_durations.py:225: error: Incompatible types in assignment (expression has type "tuple[str, tuple[int, ...]]", variable has type "tuple[str, tuple[int, ...], tuple[float, ...]]")  [assignment]
> qiskit/transpiler/instruction_durations.py:230: error: Invalid index type "tuple[str, tuple[int, ...], tuple[float, ...]]" for "dict[tuple[str, tuple[int, ...]], tuple[float, str]]"; expected type "tuple[str, tuple[int, ...]]"  [index]
> qiskit/transpiler/instruction_durations.py:240: error: Incompatible types in assignment (expression has type "float | ParameterExpression", variable has type "float")  [assignment]
> qiskit/transpiler/passes/optimization/template_matching/forward_match.py:226: error: Item "DAGOpNode" of "DAGOpNode | DAGOutNode" has no attribute "successorstovisit"  [union-attr]
> qiskit/transpiler/passes/optimization/template_matching/forward_match.py:226: error: Item "DAGOutNode" of "DAGOpNode | DAGOutNode" has no attribute "successorstovisit"  [union-attr]
> qiskit/transpiler/passes/optimization/template_matching/forward_match.py:377: error: Item "int" of "int | DAGDepNode" has no attribute "successorstovisit"  [union-attr]
> qiskit/transpiler/passes/optimization/template_matching/forward_match.py:429: error: List item 0 has incompatible type "set[int]"; expected "int"  [list-item]
> qiskit/transpiler/passes/optimization/template_matching/forward_match.py:448: error: Item "int" of "int | DAGDepNode" has no attribute "successorstovisit"  [union-attr]
1107,1112c1109,1114
< qiskit/transpiler/passes/routing/algorithms/util.py:103: error: Argument 2 to "PermutationCircuit" has incompatible type "dict[_V, Any]"; expected "dict[int | Qubit, Qubit]"  [arg-type]
< qiskit/transpiler/passes/optimization/template_matching/template_matching.py:86: error: Incompatible types in assignment (expression has type "list[Any]", variable has type "tuple[Any, ...]")  [assignment]
< qiskit/transpiler/passes/optimization/template_matching/template_matching.py:95: error: Incompatible types in assignment (expression has type "list[Any]", variable has type "tuple[Any, ...]")  [assignment]
< qiskit/transpiler/passes/optimization/template_matching/template_matching.py:97: error: Incompatible types in assignment (expression has type "list[Any]", variable has type "tuple[Any, ...]")  [assignment]
< qiskit/transpiler/passes/optimization/template_matching/template_matching.py:297: error: Incompatible types in assignment (expression has type "list[Any]", variable has type "tuple[Any, ...]")  [assignment]
< qiskit/transpiler/passes/optimization/template_matching/template_matching.py:309: error: Incompatible types in assignment (expression has type "list[Any]", variable has type "tuple[Any, ...]")  [assignment]
---
> qiskit/transpiler/passes/routing/algorithms/util.py:103: error: Argument 2 to "PermutationCircuit" has incompatible type "dict[_V, Qubit]"; expected "dict[int | Qubit, Qubit]"  [arg-type]
> qiskit/transpiler/passes/optimization/template_matching/template_matching.py:94: error: Incompatible types in assignment (expression has type "list[Any]", variable has type "tuple[Any, ...]")  [assignment]
> qiskit/transpiler/passes/optimization/template_matching/template_matching.py:103: error: Incompatible types in assignment (expression has type "list[Any]", variable has type "tuple[Any, ...]")  [assignment]
> qiskit/transpiler/passes/optimization/template_matching/template_matching.py:105: error: Incompatible types in assignment (expression has type "list[Any]", variable has type "tuple[Any, ...]")  [assignment]
> qiskit/transpiler/passes/optimization/template_matching/template_matching.py:305: error: Incompatible types in assignment (expression has type "list[Any]", variable has type "tuple[Any, ...]")  [assignment]
> qiskit/transpiler/passes/optimization/template_matching/template_matching.py:317: error: Incompatible types in assignment (expression has type "list[Any]", variable has type "tuple[Any, ...]")  [assignment]
1140,1141c1142
< qiskit/transpiler/passmanager.py:45: error: Incompatible default for argument "passes" (default has type "tuple[()]", argument has type "Task | list[Task]")  [assignment]
< qiskit/transpiler/passmanager.py:56: error: Need type annotation for "_pass_sets" (hint: "_pass_sets: List[<type>] = ...")  [var-annotated]
---
> qiskit/transpiler/passmanager.py:59: error: Argument "tasks" to "__init__" of "BasePassManager" has incompatible type "Task | Sequence[Task]"; expected "Task | list[Task]"  [arg-type]
1151c1152
< qiskit/transpiler/passmanager.py:479: note:          def append(passes: Task | list[Task], max_iteration: int = ..., **flow_controller_conditions: Any) -> None
---
> qiskit/transpiler/passmanager.py:479: note:          def append(passes: Task | list[Task], max_iteration: int | None = ..., **flow_controller_conditions: Any) -> None
1156c1157
< qiskit/transpiler/passmanager.py:487: note:          def replace(index: int, passes: BasePass | list[BasePass], max_iteration: int = ..., **flow_controller_conditions: Any) -> None
---
> qiskit/transpiler/passmanager.py:487: note:          def replace(index: int, passes: BasePass | list[BasePass], max_iteration: int | None = ..., **flow_controller_conditions: Any) -> None
1168,1178c1169,1179
< qiskit/transpiler/passes/synthesis/high_level_synthesis.py:330: error: "Operation" has no attribute "definition"  [attr-defined]
< qiskit/transpiler/passes/synthesis/high_level_synthesis.py:434: error: Item "DAGCircuit" of "QuantumCircuit | DAGCircuit | Operation" has no attribute "inverse"  [union-attr]
< qiskit/transpiler/passes/synthesis/high_level_synthesis.py:434: error: Item "Operation" of "QuantumCircuit | DAGCircuit | Operation" has no attribute "inverse"  [union-attr]
< qiskit/transpiler/passes/synthesis/high_level_synthesis.py:443: error: Item "DAGCircuit" of "DAGCircuit | Operation" has no attribute "control"  [union-attr]
< qiskit/transpiler/passes/synthesis/high_level_synthesis.py:443: error: Item "Operation" of "DAGCircuit | Operation" has no attribute "control"  [union-attr]
< qiskit/transpiler/passes/synthesis/high_level_synthesis.py:450: error: Argument 1 to "_recursively_handle_op" of "HighLevelSynthesis" has incompatible type "QuantumCircuit | DAGCircuit | Operation"; expected "Operation"  [arg-type]
< qiskit/transpiler/passes/synthesis/high_level_synthesis.py:458: error: Argument 1 to "QuantumCircuit" has incompatible type "Callable[[], Any] | Any"; expected "Register | int | Sequence[Bit]"  [arg-type]
< qiskit/transpiler/passes/synthesis/high_level_synthesis.py:458: error: Argument 2 to "QuantumCircuit" has incompatible type "Callable[[], Any] | Any"; expected "Register | int | Sequence[Bit]"  [arg-type]
< qiskit/transpiler/passes/synthesis/high_level_synthesis.py:461: error: Argument 1 to "range" has incompatible type "Callable[[], Any] | Any"; expected "SupportsIndex"  [arg-type]
< qiskit/transpiler/passes/synthesis/high_level_synthesis.py:462: error: Argument 1 to "range" has incompatible type "Callable[[], Any] | Any"; expected "SupportsIndex"  [arg-type]
< qiskit/transpiler/passes/synthesis/high_level_synthesis.py:474: error: Incompatible return value type (got "QuantumCircuit | DAGCircuit | Operation", expected "Operation | None")  [return-value]
---
> qiskit/transpiler/passes/synthesis/high_level_synthesis.py:329: error: "Operation" has no attribute "definition"  [attr-defined]
> qiskit/transpiler/passes/synthesis/high_level_synthesis.py:431: error: Item "DAGCircuit" of "QuantumCircuit | DAGCircuit | Operation" has no attribute "inverse"  [union-attr]
> qiskit/transpiler/passes/synthesis/high_level_synthesis.py:431: error: Item "Operation" of "QuantumCircuit | DAGCircuit | Operation" has no attribute "inverse"  [union-attr]
> qiskit/transpiler/passes/synthesis/high_level_synthesis.py:440: error: Item "DAGCircuit" of "DAGCircuit | Operation" has no attribute "control"  [union-attr]
> qiskit/transpiler/passes/synthesis/high_level_synthesis.py:440: error: Item "Operation" of "DAGCircuit | Operation" has no attribute "control"  [union-attr]
> qiskit/transpiler/passes/synthesis/high_level_synthesis.py:447: error: Argument 1 to "_recursively_handle_op" of "HighLevelSynthesis" has incompatible type "QuantumCircuit | DAGCircuit | Operation"; expected "Operation"  [arg-type]
> qiskit/transpiler/passes/synthesis/high_level_synthesis.py:455: error: Argument 1 to "QuantumCircuit" has incompatible type "Callable[[], Any] | Any"; expected "Register | int | Sequence[Bit]"  [arg-type]
> qiskit/transpiler/passes/synthesis/high_level_synthesis.py:455: error: Argument 2 to "QuantumCircuit" has incompatible type "Callable[[], Any] | Any"; expected "Register | int | Sequence[Bit]"  [arg-type]
> qiskit/transpiler/passes/synthesis/high_level_synthesis.py:458: error: Argument 1 to "range" has incompatible type "Callable[[], Any] | Any"; expected "SupportsIndex"  [arg-type]
> qiskit/transpiler/passes/synthesis/high_level_synthesis.py:459: error: Argument 1 to "range" has incompatible type "Callable[[], Any] | Any"; expected "SupportsIndex"  [arg-type]
> qiskit/transpiler/passes/synthesis/high_level_synthesis.py:471: error: Incompatible return value type (got "QuantumCircuit | DAGCircuit | Operation", expected "Operation | None")  [return-value]
1192,1200c1193,1194
< qiskit/transpiler/passes/optimization/optimize_1q_gates.py:97: error: Incompatible types in assignment (expression has type "tuple[float, Any, Any]", variable has type "tuple[int, int, Any]")  [assignment]
< qiskit/transpiler/passes/optimization/optimize_1q_gates.py:119: error: Incompatible types in assignment (expression has type "tuple[float, ...]", variable has type "tuple[int, int, Any]")  [assignment]
< qiskit/transpiler/passes/optimization/optimize_1q_gates.py:131: error: Incompatible types in assignment (expression has type "tuple[float, Any, int]", variable has type "tuple[int, int, int]")  [assignment]
< qiskit/transpiler/passes/optimization/optimize_1q_gates.py:139: error: Incompatible types in assignment (expression has type "tuple[float, int, Any]", variable has type "tuple[int, int, int]")  [assignment]
< qiskit/transpiler/passes/optimization/optimize_1q_gates.py:173: error: Incompatible types in assignment (expression has type "tuple[Any, float, float]", variable has type "tuple[int, int, int]")  [assignment]
< qiskit/transpiler/passes/optimization/optimize_1q_gates.py:247: error: Incompatible types in assignment (expression has type "tuple[float, int, float]", variable has type "tuple[int, int, int]")  [assignment]
< qiskit/transpiler/passes/optimization/optimize_1q_gates.py:258: error: Incompatible types in assignment (expression has type "tuple[float, float, float]", variable has type "tuple[int, int, int]")  [assignment]
< qiskit/transpiler/passes/optimization/optimize_1q_decomposition.py:185: error: Value of type "float" is not indexable  [index]
< qiskit/transpiler/passes/optimization/optimize_1q_decomposition.py:236: error: Need type annotation for "circuit_list"  [var-annotated]
---
> qiskit/transpiler/passes/optimization/optimize_1q_gates.py:119: error: Incompatible types in assignment (expression has type "tuple[float, ...]", variable has type "tuple[float, float, Any]")  [assignment]
> qiskit/transpiler/passes/optimization/optimize_1q_decomposition.py:188: error: Value of type "float" is not indexable  [index]
1205,1213c1199,1204
< qiskit/transpiler/passes/optimization/collect_multiqubit_blocks.py:175: error: Need type annotation for "savings" (hint: "savings: Dict[<type>, <type>] = ...")  [var-annotated]
< qiskit/transpiler/passes/layout/vf2_post_layout.py:196: error: Value of type "None" is not indexable  [index]
< qiskit/transpiler/passes/layout/vf2_post_layout.py:197: error: Value of type "None" is not indexable  [index]
< qiskit/transpiler/passes/layout/vf2_post_layout.py:200: error: "None" has no attribute "__iter__" (not iterable)  [attr-defined]
< qiskit/transpiler/passes/layout/vf2_post_layout.py:201: error: Value of type "None" is not indexable  [index]
< qiskit/transpiler/passes/layout/vf2_post_layout.py:269: error: Incompatible types in assignment (expression has type "dict[Any, int]", variable has type "Layout")  [assignment]
< qiskit/transpiler/passes/basis/basis_translator.py:123: error: Need type annotation for "_qargs_with_non_global_operation" (hint: "_qargs_with_non_global_operation: Dict[<type>, <type>] = ...")  [var-annotated]
< qiskit/transpiler/passes/basis/basis_translator.py:323: error: Incompatible types in assignment (expression has type "int | float | complex", variable has type "ParameterExpression")  [assignment]
< qiskit/transpiler/passes/basis/basis_translator.py:340: error: Incompatible types in assignment (expression has type "int | float | complex", variable has type "ParameterExpression")  [assignment]
---
> qiskit/transpiler/passes/optimization/collect_multiqubit_blocks.py:220: error: Argument 1 to "union_set" of "CollectMultiQBlocks" has incompatible type "int"; expected "Qubit"  [arg-type]
> qiskit/transpiler/passes/optimization/collect_multiqubit_blocks.py:222: error: Argument 1 to "find_set" of "CollectMultiQBlocks" has incompatible type "int"; expected "Qubit"  [arg-type]
> qiskit/transpiler/passes/optimization/collect_multiqubit_blocks.py:222: error: Argument 1 to "append" of "list" has incompatible type "DAGOpNode"; expected "Qubit"  [arg-type]
> qiskit/transpiler/passes/layout/vf2_post_layout.py:271: error: Incompatible types in assignment (expression has type "dict[Any, int]", variable has type "Layout")  [assignment]
> qiskit/transpiler/passes/basis/basis_translator.py:331: error: Incompatible types in assignment (expression has type "int | float | complex", variable has type "ParameterExpression")  [assignment]
> qiskit/transpiler/passes/basis/basis_translator.py:348: error: Incompatible types in assignment (expression has type "int | float | complex", variable has type "ParameterExpression")  [assignment]
1221,1222c1212,1213
< qiskit/transpiler/passes/scheduling/base_scheduler.py:249: error: "Iterable[Task]" has no attribute "append"  [attr-defined]
< qiskit/transpiler/passes/scheduling/scheduling/base_scheduler.py:48: error: "Iterable[Task]" has no attribute "append"  [attr-defined]
---
> qiskit/transpiler/passes/scheduling/base_scheduler.py:251: error: "Iterable[Task]" has no attribute "append"  [attr-defined]
> qiskit/transpiler/passes/scheduling/scheduling/base_scheduler.py:49: error: "Iterable[Task]" has no attribute "append"  [attr-defined]
1227,1230c1218,1219
< qiskit/transpiler/passes/layout/sabre_layout.py:305: error: Incompatible types in assignment (expression has type "QuantumRegister", variable has type "ndarray[Any, Any]")  [assignment]
< qiskit/transpiler/passes/layout/sabre_layout.py:467: error: Name "SwapMap" is not defined  [name-defined]
< qiskit/transpiler/passes/layout/sabre_layout.py:467: error: Name "Sequence" is not defined  [name-defined]
< qiskit/transpiler/passes/layout/sabre_layout.py:467: error: Name "NodeBlockResults" is not defined  [name-defined]
---
> qiskit/transpiler/passes/layout/sabre_layout.py:307: error: Incompatible types in assignment (expression has type "QuantumRegister", variable has type "ndarray[Any, Any]")  [assignment]
> qiskit/transpiler/passes/layout/sabre_layout.py:469: error: Name "NodeBlockResults" is not defined  [name-defined]
1247,1260c1236,1247
< qiskit/transpiler/passes/synthesis/unitary_synthesis.py:511: error: Need type annotation for "gate_lengths" (hint: "gate_lengths: Dict[<type>, <type>] = ...")  [var-annotated]
< qiskit/transpiler/passes/synthesis/unitary_synthesis.py:537: error: Need type annotation for "gate_errors" (hint: "gate_errors: Dict[<type>, <type>] = ...")  [var-annotated]
< qiskit/transpiler/passes/synthesis/unitary_synthesis.py:581: error: Incompatible types in assignment (expression has type "tuple[Any, Any]", variable has type "list[tuple[Any, Any]]")  [assignment]
< qiskit/transpiler/passes/synthesis/unitary_synthesis.py:583: error: Argument 1 to "append" of "list" has incompatible type "list[tuple[Any, Any]]"; expected "tuple[Any, Any]"  [arg-type]
< qiskit/transpiler/passes/synthesis/unitary_synthesis.py:585: error: List item 0 has incompatible type "list[tuple[Any, Any]]"; expected "tuple[Any, Any]"  [list-item]
< qiskit/transpiler/passes/synthesis/unitary_synthesis.py:614: error: Incompatible types in assignment (expression has type "tuple[Any, Any]", variable has type "list[tuple[Any, Any]]")  [assignment]
< qiskit/transpiler/passes/synthesis/unitary_synthesis.py:616: error: Argument 1 to "append" of "list" has incompatible type "list[tuple[Any, Any]]"; expected "tuple[Any, Any]"  [arg-type]
< qiskit/transpiler/passes/synthesis/unitary_synthesis.py:618: error: List item 0 has incompatible type "list[tuple[Any, Any]]"; expected "tuple[Any, Any]"  [list-item]
< qiskit/transpiler/passes/synthesis/unitary_synthesis.py:772: error: Incompatible types in assignment (expression has type "dict[Never, Never]", variable has type "float")  [assignment]
< qiskit/transpiler/passes/synthesis/unitary_synthesis.py:780: error: Unsupported target for indexed assignment ("float")  [index]
< qiskit/transpiler/passes/synthesis/unitary_synthesis.py:785: error: Unsupported target for indexed assignment ("float")  [index]
< qiskit/transpiler/passes/synthesis/unitary_synthesis.py:797: error: Incompatible types in assignment (expression has type "dict[Any, Any]", variable has type "float")  [assignment]
< qiskit/transpiler/passes/synthesis/unitary_synthesis.py:797: error: "float" has no attribute "items"  [attr-defined]
< qiskit/transpiler/passes/synthesis/unitary_synthesis.py:810: error: Incompatible types in assignment (expression has type "XXDecomposer", variable has type "TwoQubitBasisDecomposer")  [assignment]
---
> qiskit/transpiler/passes/synthesis/unitary_synthesis.py:585: error: Incompatible types in assignment (expression has type "tuple[Any, Any]", variable has type "list[tuple[Any, Any]]")  [assignment]
> qiskit/transpiler/passes/synthesis/unitary_synthesis.py:587: error: Argument 1 to "append" of "list" has incompatible type "list[tuple[Any, Any]]"; expected "tuple[Any, Any]"  [arg-type]
> qiskit/transpiler/passes/synthesis/unitary_synthesis.py:589: error: List item 0 has incompatible type "list[tuple[Any, Any]]"; expected "tuple[Any, Any]"  [list-item]
> qiskit/transpiler/passes/synthesis/unitary_synthesis.py:620: error: Incompatible types in assignment (expression has type "tuple[Any, Any]", variable has type "list[tuple[Any, Any]]")  [assignment]
> qiskit/transpiler/passes/synthesis/unitary_synthesis.py:622: error: Argument 1 to "append" of "list" has incompatible type "list[tuple[Any, Any]]"; expected "tuple[Any, Any]"  [arg-type]
> qiskit/transpiler/passes/synthesis/unitary_synthesis.py:624: error: List item 0 has incompatible type "list[tuple[Any, Any]]"; expected "tuple[Any, Any]"  [list-item]
> qiskit/transpiler/passes/synthesis/unitary_synthesis.py:778: error: Incompatible types in assignment (expression has type "dict[Never, Never]", variable has type "float")  [assignment]
> qiskit/transpiler/passes/synthesis/unitary_synthesis.py:786: error: Unsupported target for indexed assignment ("float")  [index]
> qiskit/transpiler/passes/synthesis/unitary_synthesis.py:791: error: Unsupported target for indexed assignment ("float")  [index]
> qiskit/transpiler/passes/synthesis/unitary_synthesis.py:803: error: Incompatible types in assignment (expression has type "dict[Any, Any]", variable has type "float")  [assignment]
> qiskit/transpiler/passes/synthesis/unitary_synthesis.py:803: error: "float" has no attribute "items"  [attr-defined]
> qiskit/transpiler/passes/synthesis/unitary_synthesis.py:816: error: Incompatible types in assignment (expression has type "XXDecomposer", variable has type "TwoQubitBasisDecomposer")  [assignment]
1557,1562c1544,1548
< qiskit/transpiler/preset_passmanagers/builtin_plugins.py:158: error: Incompatible return value type (got "TranspilerError", expected "PassManager")  [return-value]
< qiskit/transpiler/preset_passmanagers/builtin_plugins.py:574: error: List item 0 has incompatible type "Collect2qBlocks"; expected "TransformationPass"  [list-item]
< qiskit/transpiler/preset_passmanagers/builtin_plugins.py:601: error: "BasePass" has no attribute "__iter__" (not iterable)  [attr-defined]
< qiskit/transpiler/preset_passmanagers/builtin_plugins.py:619: error: Unsupported operand types for + ("list[AnalysisPass | Task | TransformationPass]" and "list[AnalysisPass]")  [operator]
< qiskit/transpiler/preset_passmanagers/builtin_plugins.py:760: error: Incompatible types in assignment (expression has type "SabreLayout", variable has type "VF2Layout")  [assignment]
< qiskit/transpiler/preset_passmanagers/builtin_plugins.py:788: error: Incompatible types in assignment (expression has type "SabreLayout", variable has type "VF2Layout")  [assignment]
---
> qiskit/transpiler/preset_passmanagers/builtin_plugins.py:159: error: Incompatible return value type (got "TranspilerError", expected "PassManager")  [return-value]
> qiskit/transpiler/preset_passmanagers/builtin_plugins.py:604: error: "BasePass" has no attribute "__iter__" (not iterable)  [attr-defined]
> qiskit/transpiler/preset_passmanagers/builtin_plugins.py:622: error: Unsupported operand types for + ("list[AnalysisPass | Task | BasePass]" and "list[AnalysisPass]")  [operator]
> qiskit/transpiler/preset_passmanagers/builtin_plugins.py:763: error: Incompatible types in assignment (expression has type "SabreLayout", variable has type "VF2Layout")  [assignment]
> qiskit/transpiler/preset_passmanagers/builtin_plugins.py:791: error: Incompatible types in assignment (expression has type "SabreLayout", variable has type "VF2Layout")  [assignment]
1766,1792c1752,1754
< qiskit/transpiler/coupling.py:274: error: No overload variant of "__setitem__" of "list" matches argument types "Any", "int"  [call-overload]
< qiskit/transpiler/coupling.py:274: note: Possible overload variants:
< qiskit/transpiler/coupling.py:274: note:     def __setitem__(self, SupportsIndex, None, /) -> None
< qiskit/transpiler/coupling.py:274: note:     def __setitem__(self, slice, Iterable[None], /) -> None
< qiskit/transpiler/layout.py:531: error: Incompatible return value type (got "list[None]", expected "list[int]")  [return-value]
< qiskit/transpiler/layout.py:531: note: "List" is invariant -- see https://mypy.readthedocs.io/en/stable/common_issues.html#variance
< qiskit/transpiler/layout.py:531: note: Consider using "Sequence" instead, which is covariant
< qiskit/transpiler/layout.py:531: note: Perhaps you need a type annotation for "output"? Suggestion: "list[int]"
< qiskit/transpiler/passes/basis/decompose.py:78: error: Incompatible types in assignment (expression has type "list[type[Gate]] | list[str]", variable has type "list[type[Gate] | str]")  [assignment]
< qiskit/transpiler/passes/layout/sabre_pre_layout.py:191: error: Need type annotation for "extra_edges_necessary" (hint: "extra_edges_necessary: List[<type>] = ...")  [var-annotated]
< qiskit/transpiler/passes/optimization/inverse_cancellation.py:63: error: Need type annotation for "inverse_gate_pairs_names" (hint: "inverse_gate_pairs_names: Set[<type>] = ...")  [var-annotated]
< qiskit/transpiler/passes/optimization/optimize_1q_commutation.py:93: error: Need type annotation for "adjoining_run" (hint: "adjoining_run: List[<type>] = ...")  [var-annotated]
< qiskit/transpiler/passes/optimization/optimize_1q_commutation.py:123: error: Need type annotation for "commuted"  [var-annotated]
< qiskit/transpiler/passes/optimization/optimize_cliffords.py:39: error: Need type annotation for "cur_block" (hint: "cur_block: List[<type>] = ...")  [var-annotated]
< qiskit/transpiler/passes/optimization/template_matching/template_substitution.py:139: error: Need type annotation for "predecessors" (hint: "predecessors: Set[<type>] = ...")  [var-annotated]
< qiskit/transpiler/passes/optimization/template_matching/template_substitution.py:143: error: Need type annotation for "exclude" (hint: "exclude: Set[<type>] = ...")  [var-annotated]
< qiskit/transpiler/passes/optimization/template_matching/template_substitution.py:206: error: Need type annotation for "pred" (hint: "pred: Set[<type>] = ...")  [var-annotated]
< qiskit/transpiler/passes/optimization/template_matching/template_substitution.py:211: error: Need type annotation for "succ" (hint: "succ: Set[<type>] = ...")  [var-annotated]
< qiskit/transpiler/passes/optimization/template_matching/template_substitution.py:250: error: Need type annotation for "predecessors" (hint: "predecessors: Set[<type>] = ...")  [var-annotated]
< qiskit/transpiler/passes/optimization/template_matching/template_substitution.py:276: error: Need type annotation for "predecessors" (hint: "predecessors: Set[<type>] = ...")  [var-annotated]
< qiskit/transpiler/passes/optimization/template_matching/template_substitution.py:359: error: Need type annotation for "circuit_list" (hint: "circuit_list: List[<type>] = ...")  [var-annotated]
< qiskit/transpiler/passes/optimization/template_matching/template_substitution.py:511: error: Need type annotation for "circuit_params_set" (hint: "circuit_params_set: Set[<type>] = ...")  [var-annotated]
< qiskit/transpiler/passes/optimization/template_matching/template_substitution.py:533: error: Need type annotation for "template_clash_substitutions"  [var-annotated]
< qiskit/transpiler/passes/routing/lookahead_swap.py:281: error: Need type annotation for "blocked_qubits" (hint: "blocked_qubits: Set[<type>] = ...")  [var-annotated]
< qiskit/transpiler/passes/routing/sabre_swap.py:272: error: Need type annotation for "circuit_to_dag_dict" (hint: "circuit_to_dag_dict: Dict[<type>, <type>] = ...")  [var-annotated]
< qiskit/transpiler/passes/synthesis/plugin.py:623: error: Need type annotation for "plugins_by_op" (hint: "plugins_by_op: Dict[<type>, <type>] = ...")  [var-annotated]
< Found 1491 errors in 284 files (checked 950 source files)
---
> qiskit/transpiler/passes/calibration/rzx_templates.py:51: error: Incompatible return value type (got "dict[str, Collection[Any]]", expected "dict[str, list[Any] | dict[str, int]]")  [return-value]
> qiskit/transpiler/passes/optimization/template_optimization.py:142: error: Argument 1 to "MaximalMatches" has incompatible type "list[qiskit.transpiler.passes.optimization.template_matching.backward_match.Match]"; expected "list[qiskit.transpiler.passes.optimization.template_matching.maximal_matches.Match]"  [arg-type]
> Found 1459 errors in 274 files (checked 950 source files)

Note that some errors appeared due to added types mypy couldn't derive previously.

@qiskit-bot qiskit-bot added the Community PR PRs from contributors that are not 'members' of the Qiskit repo label Dec 31, 2023
@qiskit-bot
Copy link
Collaborator

Thank you for opening a new pull request.

Before your PR can be merged it will first need to pass continuous integration tests and be reviewed. Sometimes the review process can be slow, so please be patient.

While you're waiting, please feel free to review other open PRs. While only a subset of people are authorized to approve pull requests for merging, everyone is encouraged to review open pull requests. Doing reviews helps reduce the burden on the core team and helps make the project's code better for everyone.

One or more of the the following people are requested to review this:

  • @ElePT
  • @Qiskit/terra-core
  • @nkanazawa1989
  • @woodsp-ibm

@coveralls
Copy link

coveralls commented Dec 31, 2023

Pull Request Test Coverage Report for Build 8685100353

Details

  • 217 of 217 (100.0%) changed or added relevant lines in 51 files are covered.
  • 12 unchanged lines in 3 files lost coverage.
  • Overall coverage increased (+0.01%) to 89.352%

Files with Coverage Reduction New Missed Lines %
crates/qasm2/src/expr.rs 1 94.03%
crates/qasm2/src/lex.rs 5 92.11%
crates/qasm2/src/parse.rs 6 97.15%
Totals Coverage Status
Change from base Build 8668339202: 0.01%
Covered Lines: 60197
Relevant Lines: 67371

💛 - Coveralls

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Community PR PRs from contributors that are not 'members' of the Qiskit repo
Projects
Status: No status
Development

Successfully merging this pull request may close these issues.

None yet

4 participants