@@ -29,7 +29,8 @@ def _exec_expval(self, circuit: QuantumCircuit) -> Results:
29
29
estimator = EstimatorV2 ()
30
30
result = estimator .run ([(circuit , SparsePauliOp .from_list (obs ))]).result ()
31
31
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]
33
34
34
35
def _exec_counts (self , circuit : QuantumCircuit ) -> Results :
35
36
"""Extracts counts using AerSimulator directly"""
@@ -40,7 +41,8 @@ def _exec_counts(self, circuit: QuantumCircuit) -> Results:
40
41
sim = AerSimulator ()
41
42
shots = self ._get_shots ()
42
43
result = sim .run (circuit , shots = shots ).result ()
43
- return result .get_counts ()
44
+
45
+ return result .get_counts () # type: ignore[no-any-return]
44
46
45
47
def _get_shots (self ) -> int :
46
48
"""Ensure that shots is always a number, even when user hasn't set anything."""
@@ -49,7 +51,7 @@ def _get_shots(self) -> int:
49
51
if not shots :
50
52
return 1000
51
53
52
- return shots
54
+ return int ( shots ) # to ensure that shots will be a integer (for mypy)
53
55
54
56
def _exec_quasi_dist (self , circuit : QuantumCircuit ) -> Results :
55
57
"""Extracts quasi dist using SamplerV1"""
@@ -61,7 +63,7 @@ def _exec_quasi_dist(self, circuit: QuantumCircuit) -> Results:
61
63
shots = self ._get_shots ()
62
64
result = sampler .run ([circuit ], shots = shots ).result ()
63
65
64
- return result .quasi_dists [0 ]
66
+ return result .quasi_dists [0 ] # type: ignore[no-any-return]
65
67
66
68
def run_circuit (self ) -> Results :
67
69
"""
0 commit comments