cirq-core 1.6.0.dev20250520054601__py3-none-any.whl → 1.6.0.dev20250520181654__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of cirq-core might be problematic. Click here for more details.

Files changed (289) hide show
  1. cirq/_compat.py +15 -17
  2. cirq/_compat_test.py +6 -9
  3. cirq/_doc.py +2 -2
  4. cirq/_import.py +6 -6
  5. cirq/_version.py +1 -1
  6. cirq/_version_test.py +1 -1
  7. cirq/circuits/_block_diagram_drawer.py +9 -10
  8. cirq/circuits/_box_drawing_character_data.py +6 -8
  9. cirq/circuits/_bucket_priority_queue.py +7 -7
  10. cirq/circuits/circuit.py +118 -125
  11. cirq/circuits/circuit_operation.py +38 -52
  12. cirq/circuits/circuit_test.py +4 -4
  13. cirq/circuits/frozen_circuit.py +13 -23
  14. cirq/circuits/moment.py +23 -29
  15. cirq/circuits/optimization_pass.py +4 -4
  16. cirq/circuits/optimization_pass_test.py +4 -6
  17. cirq/circuits/qasm_output.py +11 -11
  18. cirq/circuits/text_diagram_drawer.py +21 -36
  19. cirq/contrib/acquaintance/bipartite.py +5 -8
  20. cirq/contrib/acquaintance/executor.py +5 -5
  21. cirq/contrib/acquaintance/executor_test.py +3 -3
  22. cirq/contrib/acquaintance/gates.py +16 -26
  23. cirq/contrib/acquaintance/gates_test.py +3 -3
  24. cirq/contrib/acquaintance/mutation_utils.py +4 -4
  25. cirq/contrib/acquaintance/optimizers.py +4 -4
  26. cirq/contrib/acquaintance/permutation.py +15 -27
  27. cirq/contrib/acquaintance/shift.py +3 -3
  28. cirq/contrib/acquaintance/shift_swap_network.py +4 -4
  29. cirq/contrib/acquaintance/strategies/cubic.py +2 -2
  30. cirq/contrib/acquaintance/strategies/quartic_paired.py +6 -6
  31. cirq/contrib/bayesian_network/bayesian_network_gate.py +9 -10
  32. cirq/contrib/circuitdag/circuit_dag.py +2 -2
  33. cirq/contrib/custom_simulators/custom_state_simulator.py +3 -3
  34. cirq/contrib/custom_simulators/custom_state_simulator_test.py +4 -4
  35. cirq/contrib/graph_device/graph_device.py +5 -5
  36. cirq/contrib/graph_device/hypergraph.py +12 -12
  37. cirq/contrib/graph_device/uniform_graph_device.py +4 -4
  38. cirq/contrib/paulistring/clifford_optimize.py +2 -2
  39. cirq/contrib/paulistring/clifford_target_gateset.py +7 -7
  40. cirq/contrib/paulistring/pauli_string_measurement_with_readout_mitigation.py +31 -31
  41. cirq/contrib/paulistring/pauli_string_measurement_with_readout_mitigation_test.py +23 -23
  42. cirq/contrib/paulistring/recombine.py +3 -3
  43. cirq/contrib/paulistring/separate.py +2 -2
  44. cirq/contrib/qasm_import/_parser.py +20 -32
  45. cirq/contrib/qcircuit/qcircuit_diagram_info.py +3 -5
  46. cirq/contrib/quantum_volume/quantum_volume.py +24 -24
  47. cirq/contrib/quimb/density_matrix.py +12 -14
  48. cirq/contrib/quimb/mps_simulator.py +20 -20
  49. cirq/contrib/quimb/state_vector.py +6 -10
  50. cirq/contrib/quirk/export_to_quirk.py +3 -3
  51. cirq/contrib/quirk/quirk_gate.py +15 -15
  52. cirq/contrib/routing/device.py +3 -3
  53. cirq/contrib/routing/greedy.py +10 -21
  54. cirq/contrib/routing/initialization.py +2 -2
  55. cirq/contrib/routing/swap_network.py +3 -3
  56. cirq/contrib/routing/utils.py +2 -2
  57. cirq/contrib/shuffle_circuits/shuffle_circuits_with_readout_benchmarking.py +8 -8
  58. cirq/contrib/svg/svg.py +3 -3
  59. cirq/devices/grid_device_metadata.py +10 -10
  60. cirq/devices/grid_qubit.py +20 -20
  61. cirq/devices/insertion_noise_model.py +5 -5
  62. cirq/devices/line_qubit.py +13 -13
  63. cirq/devices/named_topologies.py +18 -29
  64. cirq/devices/noise_model.py +3 -3
  65. cirq/devices/noise_properties.py +2 -2
  66. cirq/devices/noise_properties_test.py +1 -3
  67. cirq/devices/noise_utils.py +7 -7
  68. cirq/devices/superconducting_qubits_noise_properties.py +21 -21
  69. cirq/devices/superconducting_qubits_noise_properties_test.py +5 -7
  70. cirq/devices/thermal_noise_model.py +14 -14
  71. cirq/devices/unconstrained_device.py +2 -2
  72. cirq/experiments/benchmarking/parallel_xeb.py +29 -31
  73. cirq/experiments/n_qubit_tomography.py +5 -7
  74. cirq/experiments/qubit_characterizations.py +29 -40
  75. cirq/experiments/qubit_characterizations_test.py +1 -1
  76. cirq/experiments/random_quantum_circuit_generation.py +19 -33
  77. cirq/experiments/random_quantum_circuit_generation_test.py +6 -6
  78. cirq/experiments/readout_confusion_matrix.py +14 -14
  79. cirq/experiments/single_qubit_readout_calibration.py +12 -12
  80. cirq/experiments/t2_decay_experiment.py +7 -7
  81. cirq/experiments/two_qubit_xeb.py +32 -32
  82. cirq/experiments/two_qubit_xeb_test.py +5 -5
  83. cirq/experiments/xeb_fitting.py +25 -25
  84. cirq/experiments/xeb_sampling.py +22 -33
  85. cirq/experiments/xeb_simulation.py +5 -5
  86. cirq/experiments/xeb_simulation_test.py +3 -3
  87. cirq/experiments/z_phase_calibration.py +19 -19
  88. cirq/interop/quirk/cells/arithmetic_cells.py +23 -36
  89. cirq/interop/quirk/cells/cell.py +9 -21
  90. cirq/interop/quirk/cells/composite_cell.py +7 -22
  91. cirq/interop/quirk/cells/control_cells.py +8 -8
  92. cirq/interop/quirk/cells/input_cells.py +4 -4
  93. cirq/interop/quirk/cells/input_rotation_cells.py +5 -5
  94. cirq/interop/quirk/cells/parse.py +20 -23
  95. cirq/interop/quirk/cells/qubit_permutation_cells.py +3 -3
  96. cirq/interop/quirk/cells/swap_cell.py +3 -3
  97. cirq/interop/quirk/cells/testing.py +5 -7
  98. cirq/interop/quirk/url_to_circuit.py +17 -33
  99. cirq/json_resolver_cache.py +6 -6
  100. cirq/linalg/decompositions.py +20 -31
  101. cirq/linalg/diagonalize.py +4 -4
  102. cirq/linalg/diagonalize_test.py +3 -4
  103. cirq/linalg/operator_spaces.py +5 -5
  104. cirq/linalg/predicates.py +7 -7
  105. cirq/linalg/transformations.py +20 -20
  106. cirq/ops/arithmetic_operation.py +13 -15
  107. cirq/ops/boolean_hamiltonian.py +17 -17
  108. cirq/ops/classically_controlled_operation.py +13 -25
  109. cirq/ops/clifford_gate.py +31 -35
  110. cirq/ops/clifford_gate_test.py +2 -3
  111. cirq/ops/common_channels.py +30 -32
  112. cirq/ops/common_gates.py +64 -74
  113. cirq/ops/control_values.py +12 -12
  114. cirq/ops/controlled_gate.py +15 -30
  115. cirq/ops/controlled_gate_test.py +5 -5
  116. cirq/ops/controlled_operation.py +12 -25
  117. cirq/ops/controlled_operation_test.py +5 -5
  118. cirq/ops/dense_pauli_string.py +23 -34
  119. cirq/ops/dense_pauli_string_test.py +1 -2
  120. cirq/ops/diagonal_gate.py +9 -20
  121. cirq/ops/diagonal_gate_test.py +1 -3
  122. cirq/ops/eigen_gate.py +11 -23
  123. cirq/ops/eigen_gate_test.py +6 -8
  124. cirq/ops/fourier_transform.py +5 -5
  125. cirq/ops/fsim_gate.py +14 -14
  126. cirq/ops/gate_operation.py +23 -44
  127. cirq/ops/gateset.py +23 -37
  128. cirq/ops/gateset_test.py +2 -2
  129. cirq/ops/global_phase_op.py +8 -10
  130. cirq/ops/greedy_qubit_manager.py +6 -6
  131. cirq/ops/identity.py +9 -9
  132. cirq/ops/kraus_channel.py +7 -7
  133. cirq/ops/linear_combinations.py +29 -48
  134. cirq/ops/matrix_gates.py +8 -8
  135. cirq/ops/measure_util.py +13 -14
  136. cirq/ops/measurement_gate.py +18 -29
  137. cirq/ops/mixed_unitary_channel.py +8 -8
  138. cirq/ops/named_qubit.py +10 -10
  139. cirq/ops/op_tree.py +7 -7
  140. cirq/ops/parallel_gate.py +5 -5
  141. cirq/ops/parity_gates.py +14 -14
  142. cirq/ops/pauli_gates.py +8 -10
  143. cirq/ops/pauli_interaction_gate.py +6 -6
  144. cirq/ops/pauli_measurement_gate.py +11 -23
  145. cirq/ops/pauli_string.py +35 -52
  146. cirq/ops/pauli_string_phasor.py +4 -14
  147. cirq/ops/pauli_string_raw_types.py +3 -3
  148. cirq/ops/pauli_sum_exponential.py +2 -2
  149. cirq/ops/permutation_gate.py +4 -4
  150. cirq/ops/phased_iswap_gate.py +9 -9
  151. cirq/ops/phased_x_gate.py +10 -10
  152. cirq/ops/phased_x_z_gate.py +11 -11
  153. cirq/ops/projector.py +6 -6
  154. cirq/ops/qubit_manager.py +6 -6
  155. cirq/ops/qubit_order.py +3 -3
  156. cirq/ops/random_gate_channel.py +4 -4
  157. cirq/ops/raw_types.py +48 -70
  158. cirq/ops/state_preparation_channel.py +3 -3
  159. cirq/ops/swap_gates.py +9 -9
  160. cirq/ops/tags.py +2 -4
  161. cirq/ops/three_qubit_gates.py +20 -38
  162. cirq/ops/two_qubit_diagonal_gate.py +5 -5
  163. cirq/ops/uniform_superposition_gate.py +2 -2
  164. cirq/ops/wait_gate.py +5 -5
  165. cirq/protocols/act_on_protocol_test.py +3 -3
  166. cirq/protocols/apply_channel_protocol.py +8 -14
  167. cirq/protocols/apply_mixture_protocol.py +14 -16
  168. cirq/protocols/apply_mixture_protocol_test.py +5 -6
  169. cirq/protocols/apply_unitary_protocol.py +17 -19
  170. cirq/protocols/circuit_diagram_info_protocol.py +19 -30
  171. cirq/protocols/decompose_protocol.py +30 -34
  172. cirq/protocols/inverse_protocol.py +7 -7
  173. cirq/protocols/json_serialization.py +32 -51
  174. cirq/protocols/json_serialization_test.py +9 -10
  175. cirq/protocols/kraus_protocol.py +4 -4
  176. cirq/protocols/kraus_protocol_test.py +3 -3
  177. cirq/protocols/measurement_key_protocol.py +11 -13
  178. cirq/protocols/mixture_protocol.py +4 -4
  179. cirq/protocols/qasm.py +11 -13
  180. cirq/protocols/qid_shape_protocol.py +6 -8
  181. cirq/qis/clifford_tableau.py +12 -12
  182. cirq/qis/measures.py +7 -7
  183. cirq/qis/quantum_state_representation.py +3 -3
  184. cirq/qis/states.py +51 -51
  185. cirq/sim/classical_simulator.py +10 -10
  186. cirq/sim/clifford/clifford_simulator.py +6 -6
  187. cirq/sim/clifford/clifford_tableau_simulation_state_test.py +1 -3
  188. cirq/sim/clifford/stabilizer_sampler.py +4 -4
  189. cirq/sim/clifford/stabilizer_state_ch_form.py +3 -3
  190. cirq/sim/density_matrix_simulation_state.py +15 -15
  191. cirq/sim/density_matrix_simulator.py +11 -11
  192. cirq/sim/density_matrix_utils.py +9 -9
  193. cirq/sim/mux.py +9 -9
  194. cirq/sim/simulation_product_state.py +9 -9
  195. cirq/sim/simulation_product_state_test.py +2 -2
  196. cirq/sim/simulation_state.py +14 -27
  197. cirq/sim/simulation_state_base.py +8 -24
  198. cirq/sim/simulation_utils.py +3 -4
  199. cirq/sim/simulator.py +28 -43
  200. cirq/sim/simulator_base.py +12 -25
  201. cirq/sim/simulator_base_test.py +6 -6
  202. cirq/sim/simulator_test.py +7 -7
  203. cirq/sim/sparse_simulator.py +8 -8
  204. cirq/sim/state_vector.py +8 -8
  205. cirq/sim/state_vector_simulation_state.py +17 -17
  206. cirq/sim/state_vector_simulator.py +4 -4
  207. cirq/study/flatten_expressions.py +12 -14
  208. cirq/study/resolver.py +9 -11
  209. cirq/study/result.py +11 -24
  210. cirq/study/sweepable.py +5 -5
  211. cirq/study/sweeps.py +27 -40
  212. cirq/testing/circuit_compare.py +5 -5
  213. cirq/testing/consistent_controlled_gate_op_test.py +7 -11
  214. cirq/testing/consistent_protocols.py +10 -10
  215. cirq/testing/consistent_protocols_test.py +7 -7
  216. cirq/testing/consistent_qasm.py +4 -4
  217. cirq/testing/consistent_qasm_test.py +2 -3
  218. cirq/testing/devices.py +4 -5
  219. cirq/testing/equals_tester.py +2 -2
  220. cirq/testing/equivalent_basis_map.py +4 -4
  221. cirq/testing/equivalent_repr_eval.py +3 -3
  222. cirq/testing/json.py +14 -14
  223. cirq/testing/logs.py +3 -3
  224. cirq/testing/no_identifier_qubit.py +2 -3
  225. cirq/testing/random_circuit.py +7 -7
  226. cirq/testing/random_circuit_test.py +3 -3
  227. cirq/transformers/analytical_decompositions/clifford_decomposition.py +16 -16
  228. cirq/transformers/analytical_decompositions/controlled_gate_decomposition.py +13 -13
  229. cirq/transformers/analytical_decompositions/cphase_to_fsim.py +5 -5
  230. cirq/transformers/analytical_decompositions/cphase_to_fsim_test.py +3 -3
  231. cirq/transformers/analytical_decompositions/pauli_string_decomposition.py +3 -3
  232. cirq/transformers/analytical_decompositions/quantum_shannon_decomposition.py +4 -4
  233. cirq/transformers/analytical_decompositions/single_qubit_decompositions.py +6 -7
  234. cirq/transformers/analytical_decompositions/single_to_two_qubit_isometry.py +2 -2
  235. cirq/transformers/analytical_decompositions/three_qubit_decomposition.py +7 -7
  236. cirq/transformers/analytical_decompositions/two_qubit_state_preparation.py +4 -4
  237. cirq/transformers/analytical_decompositions/two_qubit_to_cz.py +7 -7
  238. cirq/transformers/analytical_decompositions/two_qubit_to_fsim.py +11 -11
  239. cirq/transformers/analytical_decompositions/two_qubit_to_ms.py +5 -5
  240. cirq/transformers/analytical_decompositions/two_qubit_to_sqrt_iswap.py +14 -14
  241. cirq/transformers/dynamical_decoupling.py +13 -13
  242. cirq/transformers/dynamical_decoupling_test.py +4 -4
  243. cirq/transformers/eject_phased_paulis.py +16 -16
  244. cirq/transformers/eject_z.py +5 -7
  245. cirq/transformers/gauge_compiling/gauge_compiling.py +38 -38
  246. cirq/transformers/gauge_compiling/sqrt_cz_gauge.py +2 -2
  247. cirq/transformers/heuristic_decompositions/two_qubit_gate_tabulation.py +8 -8
  248. cirq/transformers/insertion_sort.py +5 -5
  249. cirq/transformers/measurement_transformers.py +14 -14
  250. cirq/transformers/merge_k_qubit_gates_test.py +1 -3
  251. cirq/transformers/merge_single_qubit_gates_test.py +1 -3
  252. cirq/transformers/qubit_management_transformers.py +5 -5
  253. cirq/transformers/routing/initial_mapper.py +4 -4
  254. cirq/transformers/routing/line_initial_mapper.py +9 -9
  255. cirq/transformers/routing/mapping_manager.py +7 -7
  256. cirq/transformers/routing/route_circuit_cqc.py +27 -27
  257. cirq/transformers/routing/visualize_routed_circuit.py +4 -4
  258. cirq/transformers/stratify.py +8 -8
  259. cirq/transformers/synchronize_terminal_measurements.py +6 -6
  260. cirq/transformers/target_gatesets/compilation_target_gateset.py +8 -8
  261. cirq/transformers/target_gatesets/compilation_target_gateset_test.py +2 -2
  262. cirq/transformers/target_gatesets/cz_gateset.py +4 -4
  263. cirq/transformers/target_gatesets/sqrt_iswap_gateset.py +5 -5
  264. cirq/transformers/transformer_api.py +11 -26
  265. cirq/transformers/transformer_primitives.py +24 -36
  266. cirq/transformers/transformer_primitives_test.py +3 -3
  267. cirq/value/classical_data.py +18 -18
  268. cirq/value/condition.py +8 -8
  269. cirq/value/digits.py +7 -7
  270. cirq/value/duration.py +12 -12
  271. cirq/value/linear_dict.py +8 -12
  272. cirq/value/measurement_key.py +8 -8
  273. cirq/value/product_state.py +9 -9
  274. cirq/value/value_equality_attr.py +4 -4
  275. cirq/vis/heatmap.py +23 -35
  276. cirq/work/collector.py +9 -17
  277. cirq/work/observable_grouping.py +4 -7
  278. cirq/work/observable_measurement.py +29 -41
  279. cirq/work/observable_measurement_data.py +14 -14
  280. cirq/work/observable_measurement_test.py +2 -2
  281. cirq/work/observable_settings.py +9 -10
  282. cirq/work/pauli_sum_collector.py +5 -5
  283. cirq/work/sampler.py +17 -17
  284. cirq/work/zeros_sampler.py +3 -3
  285. {cirq_core-1.6.0.dev20250520054601.dist-info → cirq_core-1.6.0.dev20250520181654.dist-info}/METADATA +1 -1
  286. {cirq_core-1.6.0.dev20250520054601.dist-info → cirq_core-1.6.0.dev20250520181654.dist-info}/RECORD +289 -289
  287. {cirq_core-1.6.0.dev20250520054601.dist-info → cirq_core-1.6.0.dev20250520181654.dist-info}/WHEEL +1 -1
  288. {cirq_core-1.6.0.dev20250520054601.dist-info → cirq_core-1.6.0.dev20250520181654.dist-info}/licenses/LICENSE +0 -0
  289. {cirq_core-1.6.0.dev20250520054601.dist-info → cirq_core-1.6.0.dev20250520181654.dist-info}/top_level.txt +0 -0
@@ -2,7 +2,7 @@
2
2
 
3
3
  from __future__ import annotations
4
4
 
5
- from typing import Any, Dict, FrozenSet, Iterable, Mapping, Tuple, TYPE_CHECKING, Union
5
+ from typing import Any, Iterable, Mapping, TYPE_CHECKING
6
6
 
7
7
  import numpy as np
8
8
 
@@ -30,8 +30,8 @@ class MixedUnitaryChannel(raw_types.Gate):
30
30
 
31
31
  def __init__(
32
32
  self,
33
- mixture: Iterable[Tuple[float, np.ndarray]],
34
- key: Union[str, cirq.MeasurementKey, None] = None,
33
+ mixture: Iterable[tuple[float, np.ndarray]],
34
+ key: str | cirq.MeasurementKey | None = None,
35
35
  validate: bool = False,
36
36
  ):
37
37
  mixture = list(mixture)
@@ -61,7 +61,7 @@ class MixedUnitaryChannel(raw_types.Gate):
61
61
 
62
62
  @staticmethod
63
63
  def from_mixture(
64
- mixture: protocols.SupportsMixture, key: Union[str, cirq.MeasurementKey, None] = None
64
+ mixture: protocols.SupportsMixture, key: str | cirq.MeasurementKey | None = None
65
65
  ):
66
66
  """Creates a copy of a mixture with the given measurement key."""
67
67
  return MixedUnitaryChannel(mixture=list(protocols.mixture(mixture)), key=key)
@@ -100,18 +100,18 @@ class MixedUnitaryChannel(raw_types.Gate):
100
100
  return self
101
101
  return MixedUnitaryChannel(mixture=self._mixture, key=key_map[str(self._key)])
102
102
 
103
- def _with_key_path_(self, path: Tuple[str, ...]):
103
+ def _with_key_path_(self, path: tuple[str, ...]):
104
104
  return MixedUnitaryChannel(
105
105
  mixture=self._mixture, key=protocols.with_key_path(self._key, path)
106
106
  )
107
107
 
108
- def _with_key_path_prefix_(self, prefix: Tuple[str, ...]):
108
+ def _with_key_path_prefix_(self, prefix: tuple[str, ...]):
109
109
  return MixedUnitaryChannel(
110
110
  mixture=self._mixture, key=protocols.with_key_path_prefix(self._key, prefix)
111
111
  )
112
112
 
113
113
  def _with_rescoped_keys_(
114
- self, path: Tuple[str, ...], bindable_keys: FrozenSet[cirq.MeasurementKey]
114
+ self, path: tuple[str, ...], bindable_keys: frozenset[cirq.MeasurementKey]
115
115
  ):
116
116
  return MixedUnitaryChannel(
117
117
  mixture=self._mixture, key=protocols.with_rescoped_keys(self._key, path, bindable_keys)
@@ -131,7 +131,7 @@ class MixedUnitaryChannel(raw_types.Gate):
131
131
  args.append(f'key=\'{self._key}\'')
132
132
  return f'cirq.MixedUnitaryChannel({", ".join(args)})'
133
133
 
134
- def _json_dict_(self) -> Dict[str, Any]:
134
+ def _json_dict_(self) -> dict[str, Any]:
135
135
  return protocols.obj_to_dict_helper(self, ['_mixture', '_key'])
136
136
 
137
137
  @classmethod
cirq/ops/named_qubit.py CHANGED
@@ -16,7 +16,7 @@ from __future__ import annotations
16
16
 
17
17
  import functools
18
18
  import weakref
19
- from typing import Any, Dict, List, Optional, Tuple, TYPE_CHECKING
19
+ from typing import Any, TYPE_CHECKING
20
20
 
21
21
  from cirq import protocols
22
22
  from cirq.ops import raw_types
@@ -31,8 +31,8 @@ class _BaseNamedQid(raw_types.Qid):
31
31
 
32
32
  _name: str
33
33
  _dimension: int
34
- _comp_key: Optional[str] = None
35
- _hash: Optional[int] = None
34
+ _comp_key: str | None = None
35
+ _hash: int | None = None
36
36
 
37
37
  def __hash__(self) -> int:
38
38
  if self._hash is None:
@@ -112,7 +112,7 @@ class NamedQid(_BaseNamedQid):
112
112
 
113
113
  # Cache of existing NamedQid instances, returned by __new__ if available.
114
114
  # Holds weak references so instances can still be garbage collected.
115
- _cache = weakref.WeakValueDictionary[Tuple[str, int], 'cirq.NamedQid']()
115
+ _cache = weakref.WeakValueDictionary[tuple[str, int], 'cirq.NamedQid']()
116
116
 
117
117
  def __new__(cls, name: str, dimension: int) -> cirq.NamedQid:
118
118
  """Initializes a `NamedQid` with a given name and dimension.
@@ -137,7 +137,7 @@ class NamedQid(_BaseNamedQid):
137
137
  return (self._name, self._dimension)
138
138
 
139
139
  # avoid pickling the _hash value, attributes are already stored with __getnewargs__
140
- def __getstate__(self) -> Dict[str, Any]:
140
+ def __getstate__(self) -> dict[str, Any]:
141
141
  return {}
142
142
 
143
143
  def __repr__(self) -> str:
@@ -147,7 +147,7 @@ class NamedQid(_BaseNamedQid):
147
147
  return f'{self._name} (d={self._dimension})'
148
148
 
149
149
  @staticmethod
150
- def range(*args, prefix: str, dimension: int) -> List[NamedQid]:
150
+ def range(*args, prefix: str, dimension: int) -> list[NamedQid]:
151
151
  """Returns a range of ``NamedQid``\\s.
152
152
 
153
153
  The range returned starts with the prefix, and followed by a qid for
@@ -170,7 +170,7 @@ class NamedQid(_BaseNamedQid):
170
170
  """
171
171
  return [NamedQid(f"{prefix}{i}", dimension=dimension) for i in range(*args)]
172
172
 
173
- def _json_dict_(self) -> Dict[str, Any]:
173
+ def _json_dict_(self) -> dict[str, Any]:
174
174
  return protocols.obj_to_dict_helper(self, ['name', 'dimension'])
175
175
 
176
176
 
@@ -209,7 +209,7 @@ class NamedQubit(_BaseNamedQid):
209
209
  return (self._name,)
210
210
 
211
211
  # avoid pickling the _hash value, attributes are already stored with __getnewargs__
212
- def __getstate__(self) -> Dict[str, Any]:
212
+ def __getstate__(self) -> dict[str, Any]:
213
213
  return {}
214
214
 
215
215
  def __str__(self) -> str:
@@ -219,7 +219,7 @@ class NamedQubit(_BaseNamedQid):
219
219
  return f'cirq.NamedQubit({self._name!r})'
220
220
 
221
221
  @staticmethod
222
- def range(*args, prefix: str) -> List[NamedQubit]:
222
+ def range(*args, prefix: str) -> list[NamedQubit]:
223
223
  r"""Returns a range of `cirq.NamedQubit`s.
224
224
 
225
225
  The range returned starts with the prefix, and followed by a qubit for
@@ -241,7 +241,7 @@ class NamedQubit(_BaseNamedQid):
241
241
  """
242
242
  return [NamedQubit(f"{prefix}{i}") for i in range(*args)]
243
243
 
244
- def _json_dict_(self) -> Dict[str, Any]:
244
+ def _json_dict_(self) -> dict[str, Any]:
245
245
  return protocols.obj_to_dict_helper(self, ['name'])
246
246
 
247
247
 
cirq/ops/op_tree.py CHANGED
@@ -16,7 +16,7 @@
16
16
 
17
17
  from __future__ import annotations
18
18
 
19
- from typing import Callable, Iterable, Iterator, NoReturn, TYPE_CHECKING, Union
19
+ from typing import Callable, Iterable, Iterator, NoReturn, TYPE_CHECKING
20
20
 
21
21
  from cirq._doc import document
22
22
  from cirq._import import LazyLoader
@@ -28,7 +28,7 @@ if TYPE_CHECKING:
28
28
  moment = LazyLoader("moment", globals(), "cirq.circuits.moment")
29
29
 
30
30
 
31
- OP_TREE = Union[Operation, Iterable['OP_TREE']]
31
+ OP_TREE = Operation | Iterable['OP_TREE']
32
32
  document(
33
33
  OP_TREE,
34
34
  """An operation or nested collections of operations.
@@ -37,10 +37,10 @@ document(
37
37
  `cirq.OP_TREE` argument:
38
38
 
39
39
  - A single operation (a `cirq.Operation`).
40
- - A list of operations (a `List[cirq.Operation]`).
41
- - A list of lists of operations (a `List[List[cirq.Operation]]`).
40
+ - A list of operations (a `list[cirq.Operation]`).
41
+ - A list of lists of operations (a `list[list[cirq.Operation]]`).
42
42
  - A list mixing operations and generators of operations
43
- (a `List[Union[cirq.Operation, Iterator[cirq.Operation]]]`).
43
+ (a `list[Union[cirq.Operation, Iterator[cirq.Operation]]]`).
44
44
  - Generally anything that can be iterated, and its items iterated, and
45
45
  so forth recursively until a bottom layer of operations is found.
46
46
  """,
@@ -49,7 +49,7 @@ document(
49
49
 
50
50
  def flatten_op_tree(
51
51
  root: OP_TREE, preserve_moments: bool = False
52
- ) -> Iterator[Union[Operation, cirq.Moment]]:
52
+ ) -> Iterator[Operation | cirq.Moment]:
53
53
  """Performs an in-order iteration of the operations (leaves) in an OP_TREE.
54
54
 
55
55
  Args:
@@ -90,7 +90,7 @@ def flatten_to_ops(root: OP_TREE) -> Iterator[Operation]:
90
90
  _bad_op_tree(root)
91
91
 
92
92
 
93
- def flatten_to_ops_or_moments(root: OP_TREE) -> Iterator[Union[Operation, cirq.Moment]]:
93
+ def flatten_to_ops_or_moments(root: OP_TREE) -> Iterator[Operation | cirq.Moment]:
94
94
  """Performs an in-order iteration OP_TREE, yielding ops and moments.
95
95
 
96
96
  Args:
cirq/ops/parallel_gate.py CHANGED
@@ -15,7 +15,7 @@
15
15
  from __future__ import annotations
16
16
 
17
17
  from types import NotImplementedType
18
- from typing import AbstractSet, Any, Dict, Optional, Tuple, TYPE_CHECKING, Union
18
+ from typing import AbstractSet, Any, TYPE_CHECKING
19
19
 
20
20
  import numpy as np
21
21
 
@@ -61,7 +61,7 @@ class ParallelGate(raw_types.Gate):
61
61
  def num_copies(self) -> int:
62
62
  return self._num_copies
63
63
 
64
- def _decompose_(self, qubits: Tuple[cirq.Qid, ...]) -> DecomposeResult:
64
+ def _decompose_(self, qubits: tuple[cirq.Qid, ...]) -> DecomposeResult:
65
65
  if len(qubits) != self.num_qubits():
66
66
  raise ValueError(f"len(qubits)={len(qubits)} should be {self.num_qubits()}")
67
67
  step = self.sub_gate.num_qubits()
@@ -98,7 +98,7 @@ class ParallelGate(raw_types.Gate):
98
98
  sub_gate=protocols.resolve_parameters(self.sub_gate, resolver, recursive)
99
99
  )
100
100
 
101
- def _unitary_(self) -> Union[np.ndarray, NotImplementedType]:
101
+ def _unitary_(self) -> np.ndarray | NotImplementedType:
102
102
  # Obtain the unitary for the single qubit gate
103
103
  single_unitary = protocols.unitary(self.sub_gate, NotImplemented)
104
104
 
@@ -114,7 +114,7 @@ class ParallelGate(raw_types.Gate):
114
114
 
115
115
  return unitary
116
116
 
117
- def _trace_distance_bound_(self) -> Optional[float]:
117
+ def _trace_distance_bound_(self) -> float | None:
118
118
  if protocols.is_parameterized(self.sub_gate):
119
119
  return None
120
120
  angle = self._num_copies * np.arcsin(protocols.trace_distance_bound(self.sub_gate))
@@ -152,7 +152,7 @@ class ParallelGate(raw_types.Gate):
152
152
  return NotImplemented
153
153
  return self.with_gate(new_gate)
154
154
 
155
- def _json_dict_(self) -> Dict[str, Any]:
155
+ def _json_dict_(self) -> dict[str, Any]:
156
156
  return protocols.obj_to_dict_helper(self, attribute_names=["sub_gate", "num_copies"])
157
157
 
158
158
 
cirq/ops/parity_gates.py CHANGED
@@ -16,7 +16,7 @@
16
16
 
17
17
  from __future__ import annotations
18
18
 
19
- from typing import Any, Dict, Iterator, List, Optional, Sequence, Tuple, TYPE_CHECKING, Union
19
+ from typing import Any, Iterator, Sequence, TYPE_CHECKING
20
20
 
21
21
  import numpy as np
22
22
  from typing_extensions import Self
@@ -73,7 +73,7 @@ class XXPowGate(gate_features.InterchangeableQubitsGate, eigen_gate.EigenGate):
73
73
  def _num_qubits_(self) -> int:
74
74
  return 2
75
75
 
76
- def _eigen_components(self) -> List[Tuple[float, np.ndarray]]:
76
+ def _eigen_components(self) -> list[tuple[float, np.ndarray]]:
77
77
  return [
78
78
  (
79
79
  0.0,
@@ -90,7 +90,7 @@ class XXPowGate(gate_features.InterchangeableQubitsGate, eigen_gate.EigenGate):
90
90
  def _eigen_shifts(self):
91
91
  return [0, 1]
92
92
 
93
- def _trace_distance_bound_(self) -> Optional[float]:
93
+ def _trace_distance_bound_(self) -> float | None:
94
94
  if self._is_parameterized_():
95
95
  return None
96
96
  return abs(np.sin(self._exponent * 0.5 * np.pi))
@@ -119,14 +119,14 @@ class XXPowGate(gate_features.InterchangeableQubitsGate, eigen_gate.EigenGate):
119
119
  def _has_stabilizer_effect_(self) -> bool:
120
120
  return self.exponent % 2 in (0, 0.5, 1, 1.5)
121
121
 
122
- def _decompose_(self, qubits: Tuple[cirq.Qid, ...]) -> Iterator[cirq.OP_TREE]:
122
+ def _decompose_(self, qubits: tuple[cirq.Qid, ...]) -> Iterator[cirq.OP_TREE]:
123
123
  yield common_gates.YPowGate(exponent=-0.5).on_each(*qubits)
124
124
  yield ZZPowGate(exponent=self.exponent, global_shift=self.global_shift)(*qubits)
125
125
  yield common_gates.YPowGate(exponent=0.5).on_each(*qubits)
126
126
 
127
127
  def _circuit_diagram_info_(
128
128
  self, args: cirq.CircuitDiagramInfoArgs
129
- ) -> Union[str, protocols.CircuitDiagramInfo]:
129
+ ) -> str | protocols.CircuitDiagramInfo:
130
130
  return protocols.CircuitDiagramInfo(
131
131
  wire_symbols=('XX', 'XX'), exponent=self._diagram_exponent(args)
132
132
  )
@@ -180,7 +180,7 @@ class YYPowGate(gate_features.InterchangeableQubitsGate, eigen_gate.EigenGate):
180
180
  def _num_qubits_(self) -> int:
181
181
  return 2
182
182
 
183
- def _eigen_components(self) -> List[Tuple[float, np.ndarray]]:
183
+ def _eigen_components(self) -> list[tuple[float, np.ndarray]]:
184
184
  return [
185
185
  (
186
186
  0.0,
@@ -199,7 +199,7 @@ class YYPowGate(gate_features.InterchangeableQubitsGate, eigen_gate.EigenGate):
199
199
  def _eigen_shifts(self):
200
200
  return [0, 1]
201
201
 
202
- def _trace_distance_bound_(self) -> Optional[float]:
202
+ def _trace_distance_bound_(self) -> float | None:
203
203
  if self._is_parameterized_():
204
204
  return None
205
205
  return abs(np.sin(self._exponent * 0.5 * np.pi))
@@ -228,7 +228,7 @@ class YYPowGate(gate_features.InterchangeableQubitsGate, eigen_gate.EigenGate):
228
228
  def _has_stabilizer_effect_(self) -> bool:
229
229
  return self.exponent % 2 in (0, 0.5, 1, 1.5)
230
230
 
231
- def _decompose_(self, qubits: Tuple[cirq.Qid, ...]) -> Iterator[cirq.OP_TREE]:
231
+ def _decompose_(self, qubits: tuple[cirq.Qid, ...]) -> Iterator[cirq.OP_TREE]:
232
232
  yield common_gates.XPowGate(exponent=0.5).on_each(*qubits)
233
233
  yield ZZPowGate(exponent=self.exponent, global_shift=self.global_shift)(*qubits)
234
234
  yield common_gates.XPowGate(exponent=-0.5).on_each(*qubits)
@@ -282,7 +282,7 @@ class ZZPowGate(gate_features.InterchangeableQubitsGate, eigen_gate.EigenGate):
282
282
 
283
283
  def _decompose_into_clifford_with_qubits_(
284
284
  self, qubits: Sequence[cirq.Qid]
285
- ) -> Sequence[Union[cirq.Operation, Sequence[cirq.Operation]]]:
285
+ ) -> Sequence[cirq.Operation | Sequence[cirq.Operation]]:
286
286
  if not self._has_stabilizer_effect_():
287
287
  return NotImplemented
288
288
  if self.exponent % 2 == 0:
@@ -308,13 +308,13 @@ class ZZPowGate(gate_features.InterchangeableQubitsGate, eigen_gate.EigenGate):
308
308
  def _has_stabilizer_effect_(self) -> bool:
309
309
  return self.exponent % 2 in (0, 0.5, 1, 1.5)
310
310
 
311
- def _eigen_components(self) -> List[Tuple[float, np.ndarray]]:
311
+ def _eigen_components(self) -> list[tuple[float, np.ndarray]]:
312
312
  return [(0, np.diag([1, 0, 0, 1])), (1, np.diag([0, 1, 1, 0]))]
313
313
 
314
314
  def _eigen_shifts(self):
315
315
  return [0, 1]
316
316
 
317
- def _trace_distance_bound_(self) -> Optional[float]:
317
+ def _trace_distance_bound_(self) -> float | None:
318
318
  if self._is_parameterized_():
319
319
  return None
320
320
  return abs(np.sin(self._exponent * 0.5 * np.pi))
@@ -324,7 +324,7 @@ class ZZPowGate(gate_features.InterchangeableQubitsGate, eigen_gate.EigenGate):
324
324
  wire_symbols=('ZZ', 'ZZ'), exponent=self._diagram_exponent(args)
325
325
  )
326
326
 
327
- def _apply_unitary_(self, args: protocols.ApplyUnitaryArgs) -> Optional[np.ndarray]:
327
+ def _apply_unitary_(self, args: protocols.ApplyUnitaryArgs) -> np.ndarray | None:
328
328
  if protocols.is_parameterized(self):
329
329
  return None
330
330
 
@@ -381,7 +381,7 @@ class MSGate(XXPowGate):
381
381
 
382
382
  def _circuit_diagram_info_(
383
383
  self, args: cirq.CircuitDiagramInfoArgs
384
- ) -> Union[str, protocols.CircuitDiagramInfo]:
384
+ ) -> str | protocols.CircuitDiagramInfo:
385
385
  angle_str = self._format_exponent_as_angle(args, order=4)
386
386
  symbol = f'MS({angle_str})'
387
387
  return protocols.CircuitDiagramInfo(wire_symbols=(symbol, symbol))
@@ -401,7 +401,7 @@ class MSGate(XXPowGate):
401
401
  def _json_namespace_(cls) -> str:
402
402
  return 'cirq'
403
403
 
404
- def _json_dict_(self) -> Dict[str, Any]:
404
+ def _json_dict_(self) -> dict[str, Any]:
405
405
  return protocols.obj_to_dict_helper(self, ["rads"])
406
406
 
407
407
  @classmethod
cirq/ops/pauli_gates.py CHANGED
@@ -16,7 +16,7 @@ from __future__ import annotations
16
16
 
17
17
  import abc
18
18
  from types import NotImplementedType
19
- from typing import Any, cast, Dict, Tuple, TYPE_CHECKING, Union
19
+ from typing import Any, cast, TYPE_CHECKING
20
20
 
21
21
  from cirq._doc import document
22
22
  from cirq._import import LazyLoader
@@ -42,7 +42,7 @@ class Pauli(raw_types.Gate, metaclass=abc.ABCMeta):
42
42
  of private subclasses are the X, Y, or Z Pauli gates defined below.
43
43
  """
44
44
 
45
- _XYZ: Tuple[Pauli, Pauli, Pauli]
45
+ _XYZ: tuple[Pauli, Pauli, Pauli]
46
46
 
47
47
  @staticmethod
48
48
  def by_index(index: int) -> Pauli:
@@ -59,9 +59,7 @@ class Pauli(raw_types.Gate, metaclass=abc.ABCMeta):
59
59
  def num_qubits(self):
60
60
  return 1
61
61
 
62
- def _commutes_(
63
- self, other: Any, *, atol: float = 1e-8
64
- ) -> Union[bool, NotImplementedType, None]:
62
+ def _commutes_(self, other: Any, *, atol: float = 1e-8) -> bool | NotImplementedType | None:
65
63
  if not isinstance(other, Pauli):
66
64
  return NotImplemented
67
65
  return self is other
@@ -74,8 +72,8 @@ class Pauli(raw_types.Gate, metaclass=abc.ABCMeta):
74
72
  return (self._index - second._index + 1) % 3 - 1
75
73
 
76
74
  def phased_pauli_product(
77
- self, other: Union[cirq.Pauli, identity.IdentityGate]
78
- ) -> Tuple[complex, Union[cirq.Pauli, identity.IdentityGate]]:
75
+ self, other: cirq.Pauli | identity.IdentityGate
76
+ ) -> tuple[complex, cirq.Pauli | identity.IdentityGate]:
79
77
  if self == other:
80
78
  return 1, identity.I
81
79
  if other is identity.I:
@@ -125,7 +123,7 @@ class _PauliX(Pauli, common_gates.XPowGate):
125
123
  return Pauli._XYZ[0]
126
124
 
127
125
  @property
128
- def basis(self) -> Dict[int, _XEigenState]:
126
+ def basis(self) -> dict[int, _XEigenState]:
129
127
  from cirq.value.product_state import _XEigenState
130
128
 
131
129
  return {+1: _XEigenState(+1), -1: _XEigenState(-1)}
@@ -149,7 +147,7 @@ class _PauliY(Pauli, common_gates.YPowGate):
149
147
  return Pauli._XYZ[1]
150
148
 
151
149
  @property
152
- def basis(self) -> Dict[int, _YEigenState]:
150
+ def basis(self) -> dict[int, _YEigenState]:
153
151
  from cirq.value.product_state import _YEigenState
154
152
 
155
153
  return {+1: _YEigenState(+1), -1: _YEigenState(-1)}
@@ -173,7 +171,7 @@ class _PauliZ(Pauli, common_gates.ZPowGate):
173
171
  return Pauli._XYZ[2]
174
172
 
175
173
  @property
176
- def basis(self) -> Dict[int, _ZEigenState]:
174
+ def basis(self) -> dict[int, _ZEigenState]:
177
175
  from cirq.value.product_state import _ZEigenState
178
176
 
179
177
  return {+1: _ZEigenState(+1), -1: _ZEigenState(-1)}
@@ -14,7 +14,7 @@
14
14
 
15
15
  from __future__ import annotations
16
16
 
17
- from typing import Any, Dict, Iterator, List, Sequence, Tuple, TYPE_CHECKING
17
+ from typing import Any, Iterator, Sequence, TYPE_CHECKING
18
18
 
19
19
  import numpy as np
20
20
 
@@ -26,7 +26,7 @@ from cirq.ops.clifford_gate import SingleQubitCliffordGate
26
26
  if TYPE_CHECKING:
27
27
  import cirq
28
28
 
29
- PAULI_EIGEN_MAP: Dict[pauli_gates.Pauli, Tuple[np.ndarray, np.ndarray]] = {
29
+ PAULI_EIGEN_MAP: dict[pauli_gates.Pauli, tuple[np.ndarray, np.ndarray]] = {
30
30
  pauli_gates.X: (np.array([[0.5, 0.5], [0.5, 0.5]]), np.array([[0.5, -0.5], [-0.5, 0.5]])),
31
31
  pauli_gates.Y: (np.array([[0.5, -0.5j], [0.5j, 0.5]]), np.array([[0.5, 0.5j], [-0.5j, 0.5]])),
32
32
  pauli_gates.Z: (np.diag([1, 0]), np.diag([0, 1])),
@@ -105,10 +105,10 @@ class PauliInteractionGate(gate_features.InterchangeableQubitsGate, eigen_gate.E
105
105
  self.pauli0, self.invert0, self.pauli1, self.invert1, exponent=exponent
106
106
  )
107
107
 
108
- def _eigen_shifts(self) -> List[float]:
108
+ def _eigen_shifts(self) -> list[float]:
109
109
  return [0.0, 1.0]
110
110
 
111
- def _eigen_components(self) -> List[Tuple[float, np.ndarray]]:
111
+ def _eigen_components(self) -> list[tuple[float, np.ndarray]]:
112
112
  comp1 = np.kron(
113
113
  PAULI_EIGEN_MAP[self.pauli0][not self.invert0],
114
114
  PAULI_EIGEN_MAP[self.pauli1][not self.invert1],
@@ -130,7 +130,7 @@ class PauliInteractionGate(gate_features.InterchangeableQubitsGate, eigen_gate.E
130
130
  yield right_gate1(q1)
131
131
 
132
132
  def _circuit_diagram_info_(self, args: cirq.CircuitDiagramInfoArgs) -> cirq.CircuitDiagramInfo:
133
- labels: Dict[cirq.Pauli, str] = {pauli_gates.X: 'X', pauli_gates.Y: 'Y', pauli_gates.Z: '@'}
133
+ labels: dict[cirq.Pauli, str] = {pauli_gates.X: 'X', pauli_gates.Y: 'Y', pauli_gates.Z: '@'}
134
134
  l0 = labels[self.pauli0]
135
135
  l1 = labels[self.pauli1]
136
136
  # Add brackets around letter if inverted
@@ -149,7 +149,7 @@ class PauliInteractionGate(gate_features.InterchangeableQubitsGate, eigen_gate.E
149
149
  return base
150
150
  return f'({base}**{proper_repr(self._exponent)})'
151
151
 
152
- def _json_dict_(self) -> Dict[str, Any]:
152
+ def _json_dict_(self) -> dict[str, Any]:
153
153
  return protocols.obj_to_dict_helper(self, ["pauli0", "invert0", "pauli1", "invert1"])
154
154
 
155
155
 
@@ -14,19 +14,7 @@
14
14
 
15
15
  from __future__ import annotations
16
16
 
17
- from typing import (
18
- Any,
19
- cast,
20
- Dict,
21
- FrozenSet,
22
- Iterable,
23
- Iterator,
24
- Mapping,
25
- Sequence,
26
- Tuple,
27
- TYPE_CHECKING,
28
- Union,
29
- )
17
+ from typing import Any, cast, Iterable, Iterator, Mapping, Sequence, TYPE_CHECKING
30
18
 
31
19
  from cirq import protocols, value
32
20
  from cirq.ops import (
@@ -52,8 +40,8 @@ class PauliMeasurementGate(raw_types.Gate):
52
40
 
53
41
  def __init__(
54
42
  self,
55
- observable: Union[cirq.BaseDensePauliString, Iterable[cirq.Pauli]],
56
- key: Union[str, cirq.MeasurementKey] = '',
43
+ observable: cirq.BaseDensePauliString | Iterable[cirq.Pauli],
44
+ key: str | cirq.MeasurementKey = '',
57
45
  ) -> None:
58
46
  """Inits PauliMeasurementGate.
59
47
 
@@ -94,26 +82,26 @@ class PauliMeasurementGate(raw_types.Gate):
94
82
  def mkey(self) -> cirq.MeasurementKey:
95
83
  return self._mkey
96
84
 
97
- def _qid_shape_(self) -> Tuple[int, ...]:
85
+ def _qid_shape_(self) -> tuple[int, ...]:
98
86
  return (2,) * len(self._observable)
99
87
 
100
88
  def _has_unitary_(self) -> bool:
101
89
  return False
102
90
 
103
- def with_key(self, key: Union[str, cirq.MeasurementKey]) -> PauliMeasurementGate:
91
+ def with_key(self, key: str | cirq.MeasurementKey) -> PauliMeasurementGate:
104
92
  """Creates a pauli measurement gate with a new key but otherwise identical."""
105
93
  if key == self.key:
106
94
  return self
107
95
  return PauliMeasurementGate(self._observable, key=key)
108
96
 
109
- def _with_key_path_(self, path: Tuple[str, ...]) -> PauliMeasurementGate:
97
+ def _with_key_path_(self, path: tuple[str, ...]) -> PauliMeasurementGate:
110
98
  return self.with_key(self.mkey._with_key_path_(path))
111
99
 
112
- def _with_key_path_prefix_(self, prefix: Tuple[str, ...]) -> PauliMeasurementGate:
100
+ def _with_key_path_prefix_(self, prefix: tuple[str, ...]) -> PauliMeasurementGate:
113
101
  return self.with_key(self.mkey._with_key_path_prefix_(prefix))
114
102
 
115
103
  def _with_rescoped_keys_(
116
- self, path: Tuple[str, ...], bindable_keys: FrozenSet[cirq.MeasurementKey]
104
+ self, path: tuple[str, ...], bindable_keys: frozenset[cirq.MeasurementKey]
117
105
  ) -> PauliMeasurementGate:
118
106
  return self.with_key(protocols.with_rescoped_keys(self.mkey, path, bindable_keys))
119
107
 
@@ -121,7 +109,7 @@ class PauliMeasurementGate(raw_types.Gate):
121
109
  return self.with_key(protocols.with_measurement_key_mapping(self.mkey, key_map))
122
110
 
123
111
  def with_observable(
124
- self, observable: Union[cirq.BaseDensePauliString, Iterable[cirq.Pauli]]
112
+ self, observable: cirq.BaseDensePauliString | Iterable[cirq.Pauli]
125
113
  ) -> PauliMeasurementGate:
126
114
  """Creates a pauli measurement gate with the new observable and same key."""
127
115
  if (
@@ -146,7 +134,7 @@ class PauliMeasurementGate(raw_types.Gate):
146
134
  return self._observable
147
135
 
148
136
  def _decompose_(
149
- self, qubits: Tuple[cirq.Qid, ...]
137
+ self, qubits: tuple[cirq.Qid, ...]
150
138
  ) -> Iterator[protocols.decompose_protocol.DecomposeResult]:
151
139
  any_qubit = qubits[0]
152
140
  to_z_ops = op_tree.freeze_op_tree(self._observable.on(*qubits).to_z_basis_ops())
@@ -189,7 +177,7 @@ class PauliMeasurementGate(raw_types.Gate):
189
177
  def _value_equality_values_(self) -> Any:
190
178
  return self.key, self._observable
191
179
 
192
- def _json_dict_(self) -> Dict[str, Any]:
180
+ def _json_dict_(self) -> dict[str, Any]:
193
181
  return {'observable': self._observable, 'key': self.key}
194
182
 
195
183
  @classmethod