Skip to content

Commit f188e58

Browse files
committed
fixed types
1 parent 37bb94d commit f188e58

File tree

5 files changed

+2769
-5
lines changed

5 files changed

+2769
-5
lines changed

aer_plugin/backends/aer.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ def _exec_expval(self, circuit: QuantumCircuit) -> Results:
2929
estimator = EstimatorV2()
3030
result = estimator.run([(circuit, SparsePauliOp.from_list(obs))]).result()
3131

32-
return result[0].data.evs
32+
# to ensure the expval result will be a flot (for mypy)
33+
return float(result[0].data.evs) # type: ignore[attr-defined]
3334

3435
def _exec_counts(self, circuit: QuantumCircuit) -> Results:
3536
"""Extracts counts using AerSimulator directly"""
@@ -40,7 +41,8 @@ def _exec_counts(self, circuit: QuantumCircuit) -> Results:
4041
sim = AerSimulator()
4142
shots = self._get_shots()
4243
result = sim.run(circuit, shots=shots).result()
43-
return result.get_counts()
44+
45+
return result.get_counts() # type: ignore[no-any-return]
4446

4547
def _get_shots(self) -> int:
4648
"""Ensure that shots is always a number, even when user hasn't set anything."""
@@ -49,7 +51,7 @@ def _get_shots(self) -> int:
4951
if not shots:
5052
return 1000
5153

52-
return shots
54+
return int(shots) # to ensure that shots will be a integer (for mypy)
5355

5456
def _exec_quasi_dist(self, circuit: QuantumCircuit) -> Results:
5557
"""Extracts quasi dist using SamplerV1"""
@@ -61,7 +63,7 @@ def _exec_quasi_dist(self, circuit: QuantumCircuit) -> Results:
6163
shots = self._get_shots()
6264
result = sampler.run([circuit], shots=shots).result()
6365

64-
return result.quasi_dists[0]
66+
return result.quasi_dists[0] # type: ignore[no-any-return]
6567

6668
def run_circuit(self) -> Results:
6769
"""

aer_plugin/interface.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@
1212
Metadata = Dict[Any, Any]
1313
ResultType = str
1414
QasmFilePath = str
15-
Results = Dict[str|float|int, float] | float
15+
Results = Dict[str | float | int, float] | float
16+
1617

1718
def check_backend(func):
1819
"""

0 commit comments

Comments
 (0)