@@ -317,7 +317,9 @@ def __init__(
317
317
318
318
self .api_handler .provider = provider
319
319
320
- self ._process_circuits_options = cast (dict [str , Any ], kwargs .get ("options" , {}))
320
+ self ._process_circuits_options = cast (
321
+ "dict[str, Any]" , kwargs .get ("options" , {})
322
+ )
321
323
322
324
self ._local_emulator_handles : dict [
323
325
ResultHandle ,
@@ -608,7 +610,7 @@ def _gate_set(self) -> set[OpType]:
608
610
return (
609
611
_ALL_GATES
610
612
if self ._MACHINE_DEBUG
611
- else cast (BackendInfo , self .backend_info ).gate_set
613
+ else cast (" BackendInfo" , self .backend_info ).gate_set
612
614
)
613
615
614
616
@property
@@ -620,7 +622,7 @@ def required_predicates(self) -> list[Predicate]:
620
622
if not self ._MACHINE_DEBUG :
621
623
assert self .backend_info is not None
622
624
preds .append (MaxNQubitsPredicate (self .backend_info .n_nodes ))
623
- preds .append (MaxNClRegPredicate (cast (int , self .backend_info .n_cl_reg )))
625
+ preds .append (MaxNClRegPredicate (cast (" int" , self .backend_info .n_cl_reg )))
624
626
if self .simulator_type == "stabilizer" :
625
627
preds .append (CliffordCircuitPredicate ())
626
628
@@ -899,7 +901,7 @@ def get_jobid(handle: ResultHandle) -> str:
899
901
:param handle: result handle.
900
902
:return: Quantinuum API Job ID string.
901
903
"""
902
- return cast (str , handle [0 ])
904
+ return cast (" str" , handle [0 ])
903
905
904
906
@staticmethod
905
907
def get_ppcirc_rep (handle : ResultHandle ) -> Any :
@@ -909,7 +911,7 @@ def get_ppcirc_rep(handle: ResultHandle) -> Any:
909
911
:param handle: result handle
910
912
:return: serialized post-processing circuit, if any
911
913
"""
912
- return json .loads (cast (str , handle [1 ]))
914
+ return json .loads (cast (" str" , handle [1 ]))
913
915
914
916
@staticmethod
915
917
def get_results_width (handle : ResultHandle ) -> Optional [int ]:
@@ -918,7 +920,7 @@ def get_results_width(handle: ResultHandle) -> Optional[int]:
918
920
:param handle: result handle
919
921
:return: truncation width of results, if any
920
922
"""
921
- n = cast (int , handle [2 ])
923
+ n = cast (" int" , handle [2 ])
922
924
if n == - 1 :
923
925
return None
924
926
else :
@@ -931,7 +933,7 @@ def get_results_selection(handle: ResultHandle) -> Any:
931
933
of the expected results in the response. If None, then all results in the
932
934
response are used, in lexicographic order.
933
935
"""
934
- s = cast (str , handle [3 ])
936
+ s = cast (" str" , handle [3 ])
935
937
if s == "" :
936
938
return None
937
939
bits = json .loads (s )
@@ -1051,7 +1053,7 @@ def submit_program(
1051
1053
1052
1054
# extract job ID from response
1053
1055
return ResultHandle (
1054
- cast (str , jobdict ["job" ]),
1056
+ cast (" str" , jobdict ["job" ]),
1055
1057
"null" ,
1056
1058
- 1 if results_selection is None else len (results_selection ),
1057
1059
json .dumps (results_selection ),
@@ -1088,7 +1090,7 @@ def process_circuits(
1088
1090
* `request_options`: extra options to add to the request body as a
1089
1091
json-style dictionary
1090
1092
* `language`: languange for submission, of type :py:class:`Language`, default
1091
- QASM .
1093
+ QIR .
1092
1094
* `leakage_detection`: if true, adds additional Qubit and Bit to Circuit
1093
1095
to detect leakage errors. Run `prune_shots_detected_as_leaky` on returned
1094
1096
BackendResult to get counts with leakage errors removed.
@@ -1107,7 +1109,7 @@ def process_circuits(
1107
1109
)
1108
1110
1109
1111
if kwargs .get ("leakage_detection" , False ):
1110
- n_device_nodes : int = cast (int , self .backend_info .n_nodes ) # type: ignore
1112
+ n_device_nodes : int = cast (" int" , self .backend_info .n_nodes ) # type: ignore
1111
1113
n_leakage_detection_qubits : int = kwargs .get ( # type: ignore
1112
1114
"n_leakage_detection_qubits" , n_device_nodes
1113
1115
)
@@ -1127,17 +1129,17 @@ def process_circuits(
1127
1129
if valid_check :
1128
1130
self ._check_all_circuits (circuits )
1129
1131
1130
- postprocess = cast (bool , kwargs .get ("postprocess" , False ))
1132
+ postprocess = cast (" bool" , kwargs .get ("postprocess" , False ))
1131
1133
simplify_initial = kwargs .get ("simplify_initial" , False )
1132
- noisy_simulation = cast (bool , kwargs .get ("noisy_simulation" , True ))
1134
+ noisy_simulation = cast (" bool" , kwargs .get ("noisy_simulation" , True ))
1133
1135
1134
- group = cast (Optional [str ], kwargs .get ("group" , self ._group ))
1136
+ group = cast (" Optional[str]" , kwargs .get ("group" , self ._group ))
1135
1137
1136
- wasm_fh = cast (Optional [WasmFileHandler ], kwargs .get ("wasm_file_handler" ))
1138
+ wasm_fh = cast (" Optional[WasmFileHandler]" , kwargs .get ("wasm_file_handler" ))
1137
1139
1138
- pytket_pass = cast (Optional [BasePass ], kwargs .get ("pytketpass" ))
1140
+ pytket_pass = cast (" Optional[BasePass]" , kwargs .get ("pytketpass" ))
1139
1141
1140
- language : Language = cast (Language , kwargs .get ("language" , Language .QIR ))
1142
+ language : Language = cast (" Language" , kwargs .get ("language" , Language .QIR ))
1141
1143
1142
1144
handle_list = []
1143
1145
@@ -1216,7 +1218,7 @@ def process_circuits(
1216
1218
1217
1219
quantinuum_circ = b64encode (
1218
1220
cast (
1219
- bytes ,
1221
+ " bytes" ,
1220
1222
pytket_to_qir (
1221
1223
c0 ,
1222
1224
"circuit generated by pytket-qir" ,
@@ -1250,9 +1252,9 @@ def process_circuits(
1250
1252
group = group ,
1251
1253
wasm_file_handler = wasm_fh ,
1252
1254
pytket_pass = pytket_pass ,
1253
- options = cast (dict [str , Any ], kwargs .get ("options" , {})),
1255
+ options = cast (" dict[str, Any]" , kwargs .get ("options" , {})),
1254
1256
request_options = cast (
1255
- dict [str , Any ], kwargs .get ("request_options" , {})
1257
+ " dict[str, Any]" , kwargs .get ("request_options" , {})
1256
1258
),
1257
1259
)
1258
1260
@@ -1298,7 +1300,7 @@ def start_batch(
1298
1300
# to batch will be recognised as being added to an existing batch
1299
1301
self .api_handler .retrieve_job_status (
1300
1302
self .get_jobid (h1 ),
1301
- use_websocket = cast (bool , kwargs .get ("use_websocket" , True )),
1303
+ use_websocket = cast (" bool" , kwargs .get ("use_websocket" , True )),
1302
1304
)
1303
1305
return h1
1304
1306
@@ -1379,7 +1381,7 @@ def circuit_status(
1379
1381
):
1380
1382
return CircuitStatus (StatusEnum .COMPLETED )
1381
1383
1382
- use_websocket = cast (bool , kwargs .get ("use_websocket" , True ))
1384
+ use_websocket = cast (" bool" , kwargs .get ("use_websocket" , True ))
1383
1385
# TODO check queue position and add to message
1384
1386
try :
1385
1387
response = self .api_handler .retrieve_job_status (
@@ -1496,7 +1498,7 @@ def get_result(self, handle: ResultHandle, **kwargs: KwargTypes) -> BackendResul
1496
1498
wait = kwargs .get ("wait" )
1497
1499
if wait is not None :
1498
1500
wait = int (wait )
1499
- use_websocket = cast (Optional [bool ], kwargs .get ("use_websocket" ))
1501
+ use_websocket = cast (" Optional[bool]" , kwargs .get ("use_websocket" ))
1500
1502
1501
1503
job_retrieve = self ._retrieve_job (jobid , timeout , wait , use_websocket )
1502
1504
circ_status = _parse_status (job_retrieve )
@@ -1692,7 +1694,7 @@ def conv_int(res: str) -> list:
1692
1694
array_dict [creg ] = array_dict [creg ][:, :n_bits ]
1693
1695
1694
1696
stacked_array = cast (
1695
- Sequence [Sequence [int ]],
1697
+ " Sequence[Sequence[int]]" ,
1696
1698
np .hstack ([array_dict [name ] for name in reversed_creg_names ]),
1697
1699
)
1698
1700
else :
0 commit comments