classiq 0.52.0__py3-none-any.whl → 0.54.0__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.
Files changed (303) hide show
  1. classiq/__init__.py +1 -3
  2. classiq/_analyzer_extras/_ipywidgets_async_extension.py +2 -1
  3. classiq/_internals/__init__.py +0 -20
  4. classiq/_internals/api_wrapper.py +23 -17
  5. classiq/_internals/async_utils.py +1 -3
  6. classiq/_internals/authentication/auth0.py +5 -5
  7. classiq/_internals/authentication/device.py +5 -4
  8. classiq/_internals/authentication/password_manager.py +3 -3
  9. classiq/_internals/authentication/token_manager.py +3 -2
  10. classiq/_internals/client.py +11 -13
  11. classiq/_internals/config.py +2 -2
  12. classiq/_internals/jobs.py +7 -6
  13. classiq/_internals/type_validation.py +9 -9
  14. classiq/analyzer/__init__.py +1 -3
  15. classiq/analyzer/analyzer.py +8 -7
  16. classiq/analyzer/analyzer_utilities.py +8 -8
  17. classiq/analyzer/rb.py +11 -11
  18. classiq/applications/__init__.py +1 -3
  19. classiq/applications/chemistry/__init__.py +1 -3
  20. classiq/applications/chemistry/ansatz_parameters.py +4 -4
  21. classiq/applications/chemistry/chemistry_model_constructor.py +10 -9
  22. classiq/applications/combinatorial_helpers/combinatorial_problem_utils.py +26 -9
  23. classiq/applications/combinatorial_helpers/encoding_mapping.py +10 -10
  24. classiq/applications/combinatorial_helpers/encoding_utils.py +4 -4
  25. classiq/applications/combinatorial_helpers/memory.py +5 -7
  26. classiq/applications/combinatorial_helpers/optimization_model.py +43 -24
  27. classiq/applications/combinatorial_helpers/pauli_helpers/pauli_utils.py +4 -6
  28. classiq/applications/combinatorial_helpers/pyomo_utils.py +95 -24
  29. classiq/applications/combinatorial_helpers/sympy_utils.py +2 -2
  30. classiq/applications/combinatorial_helpers/transformations/encoding.py +8 -8
  31. classiq/applications/combinatorial_helpers/transformations/fixed_variables.py +5 -5
  32. classiq/applications/combinatorial_helpers/transformations/ising_converter.py +7 -9
  33. classiq/applications/combinatorial_helpers/transformations/penalty.py +1 -2
  34. classiq/applications/combinatorial_helpers/transformations/sign_seperation.py +1 -2
  35. classiq/applications/combinatorial_helpers/transformations/slack_variables.py +1 -2
  36. classiq/applications/combinatorial_optimization/__init__.py +1 -3
  37. classiq/applications/combinatorial_optimization/combinatorial_optimization_config.py +2 -2
  38. classiq/applications/combinatorial_optimization/examples/__init__.py +1 -3
  39. classiq/applications/finance/__init__.py +1 -3
  40. classiq/applications/grover/__init__.py +1 -3
  41. classiq/applications/grover/grover_model_constructor.py +7 -9
  42. classiq/applications/hamiltonian/pauli_decomposition.py +6 -6
  43. classiq/applications/qnn/__init__.py +1 -3
  44. classiq/applications/qnn/circuit_utils.py +5 -5
  45. classiq/applications/qnn/datasets/__init__.py +1 -3
  46. classiq/applications/qnn/datasets/dataset_base_classes.py +5 -4
  47. classiq/applications/qnn/datasets/dataset_parity.py +2 -2
  48. classiq/applications/qnn/gradients/simple_quantum_gradient.py +2 -1
  49. classiq/applications/qnn/qlayer.py +25 -6
  50. classiq/applications/qnn/torch_utils.py +2 -2
  51. classiq/applications/qnn/types.py +5 -5
  52. classiq/applications/qsvm/qsvm.py +1 -3
  53. classiq/applications/qsvm/qsvm_data_generation.py +3 -3
  54. classiq/applications/qsvm/qsvm_model_constructor.py +5 -5
  55. classiq/execution/__init__.py +3 -3
  56. classiq/execution/all_hardware_devices.py +1 -3
  57. classiq/execution/execution_session.py +57 -16
  58. classiq/execution/iqcc.py +1 -1
  59. classiq/execution/jobs.py +4 -4
  60. classiq/execution/qaoa.py +84 -0
  61. classiq/execution/qnn.py +3 -3
  62. classiq/executor.py +4 -4
  63. classiq/interface/_version.py +1 -1
  64. classiq/interface/analyzer/analysis_params.py +9 -10
  65. classiq/interface/analyzer/cytoscape_graph.py +5 -5
  66. classiq/interface/analyzer/result.py +17 -17
  67. classiq/interface/applications/qsvm.py +6 -10
  68. classiq/interface/backend/backend_preferences.py +4 -3
  69. classiq/interface/backend/ionq/ionq_quantum_program.py +4 -5
  70. classiq/interface/backend/pydantic_backend.py +1 -2
  71. classiq/interface/chemistry/fermionic_operator.py +5 -5
  72. classiq/interface/chemistry/ground_state_problem.py +7 -8
  73. classiq/interface/chemistry/molecule.py +4 -4
  74. classiq/interface/chemistry/operator.py +11 -13
  75. classiq/interface/combinatorial_optimization/examples/ascending_sequence.py +1 -3
  76. classiq/interface/combinatorial_optimization/examples/integer_portfolio_optimization.py +2 -4
  77. classiq/interface/combinatorial_optimization/examples/knapsack.py +3 -3
  78. classiq/interface/combinatorial_optimization/examples/mht.py +2 -3
  79. classiq/interface/combinatorial_optimization/examples/portfolio_variations.py +2 -2
  80. classiq/interface/combinatorial_optimization/examples/set_cover.py +1 -2
  81. classiq/interface/combinatorial_optimization/mht_qaoa_input.py +5 -7
  82. classiq/interface/combinatorial_optimization/optimization_problem.py +2 -2
  83. classiq/interface/combinatorial_optimization/result.py +1 -3
  84. classiq/interface/debug_info/debug_info.py +8 -7
  85. classiq/interface/exceptions.py +11 -7
  86. classiq/interface/execution/iqcc.py +1 -3
  87. classiq/interface/execution/jobs.py +2 -2
  88. classiq/interface/execution/primitives.py +3 -3
  89. classiq/interface/executor/aws_execution_cost.py +4 -4
  90. classiq/interface/executor/execution_request.py +2 -3
  91. classiq/interface/executor/execution_result.py +3 -3
  92. classiq/interface/executor/iqae_result.py +3 -5
  93. classiq/interface/executor/optimizer_preferences.py +2 -2
  94. classiq/interface/executor/quantum_code.py +6 -6
  95. classiq/interface/executor/register_initialization.py +2 -4
  96. classiq/interface/executor/result.py +35 -28
  97. classiq/interface/executor/vqe_result.py +8 -8
  98. classiq/interface/finance/function_input.py +2 -2
  99. classiq/interface/finance/gaussian_model_input.py +5 -5
  100. classiq/interface/finance/log_normal_model_input.py +2 -2
  101. classiq/interface/finance/model_input.py +1 -2
  102. classiq/interface/generator/adjacency.py +1 -3
  103. classiq/interface/generator/ansatz_library.py +4 -4
  104. classiq/interface/generator/application_apis/finance_declarations.py +1 -1
  105. classiq/interface/generator/arith/argument_utils.py +3 -3
  106. classiq/interface/generator/arith/arithmetic.py +7 -7
  107. classiq/interface/generator/arith/arithmetic_arg_type_validator.py +5 -5
  108. classiq/interface/generator/arith/arithmetic_expression_abc.py +11 -11
  109. classiq/interface/generator/arith/arithmetic_expression_parser.py +8 -7
  110. classiq/interface/generator/arith/arithmetic_expression_validator.py +8 -8
  111. classiq/interface/generator/arith/arithmetic_operations.py +4 -3
  112. classiq/interface/generator/arith/arithmetic_param_getters.py +6 -6
  113. classiq/interface/generator/arith/arithmetic_result_builder.py +9 -9
  114. classiq/interface/generator/arith/ast_node_rewrite.py +2 -1
  115. classiq/interface/generator/arith/binary_ops.py +10 -13
  116. classiq/interface/generator/arith/extremum_operations.py +3 -2
  117. classiq/interface/generator/arith/logical_ops.py +7 -6
  118. classiq/interface/generator/arith/number_utils.py +4 -4
  119. classiq/interface/generator/arith/register_user_input.py +4 -4
  120. classiq/interface/generator/arith/unary_ops.py +2 -1
  121. classiq/interface/generator/builtin_api_builder.py +2 -1
  122. classiq/interface/generator/circuit_code/circuit_code.py +4 -4
  123. classiq/interface/generator/circuit_code/types_and_constants.py +3 -5
  124. classiq/interface/generator/complex_type.py +1 -2
  125. classiq/interface/generator/control_state.py +2 -2
  126. classiq/interface/generator/custom_ansatz.py +1 -3
  127. classiq/interface/generator/distance.py +3 -5
  128. classiq/interface/generator/excitations.py +3 -2
  129. classiq/interface/generator/expressions/enums/finance_functions.py +1 -3
  130. classiq/interface/generator/expressions/evaluated_expression.py +4 -3
  131. classiq/interface/generator/expressions/expression.py +4 -5
  132. classiq/interface/generator/expressions/expression_constants.py +4 -4
  133. classiq/interface/generator/expressions/qmod_qarray_proxy.py +2 -1
  134. classiq/interface/generator/expressions/qmod_qscalar_proxy.py +2 -1
  135. classiq/interface/generator/expressions/qmod_qstruct_proxy.py +2 -1
  136. classiq/interface/generator/expressions/qmod_sized_proxy.py +2 -1
  137. classiq/interface/generator/expressions/qmod_struct_instance.py +2 -1
  138. classiq/interface/generator/expressions/sympy_supported_expressions.py +11 -13
  139. classiq/interface/generator/finance.py +2 -2
  140. classiq/interface/generator/function_param_library.py +6 -6
  141. classiq/interface/generator/function_params.py +13 -19
  142. classiq/interface/generator/functions/classical_function_declaration.py +4 -3
  143. classiq/interface/generator/functions/classical_type.py +13 -13
  144. classiq/interface/generator/functions/concrete_types.py +1 -2
  145. classiq/interface/generator/functions/function_declaration.py +1 -1
  146. classiq/interface/generator/functions/qmod_python_interface.py +2 -1
  147. classiq/interface/generator/functions/type_name.py +3 -2
  148. classiq/interface/generator/generated_circuit_data.py +34 -22
  149. classiq/interface/generator/grover_diffuser.py +7 -7
  150. classiq/interface/generator/grover_operator.py +2 -2
  151. classiq/interface/generator/hardware/hardware_data.py +7 -6
  152. classiq/interface/generator/hardware_efficient_ansatz.py +8 -8
  153. classiq/interface/generator/identity.py +5 -6
  154. classiq/interface/generator/linear_pauli_rotations.py +6 -6
  155. classiq/interface/generator/mcu.py +2 -2
  156. classiq/interface/generator/mcx.py +6 -6
  157. classiq/interface/generator/model/__init__.py +1 -3
  158. classiq/interface/generator/model/constraints.py +2 -2
  159. classiq/interface/generator/model/model.py +5 -6
  160. classiq/interface/generator/model/preferences/preferences.py +7 -6
  161. classiq/interface/generator/model/quantum_register.py +6 -11
  162. classiq/interface/generator/oracles/arithmetic_oracle.py +1 -2
  163. classiq/interface/generator/oracles/custom_oracle.py +2 -2
  164. classiq/interface/generator/oracles/oracle_abc.py +6 -5
  165. classiq/interface/generator/partitioned_register.py +6 -5
  166. classiq/interface/generator/piecewise_linear_amplitude_loading.py +8 -7
  167. classiq/interface/generator/qpe.py +4 -4
  168. classiq/interface/generator/qsvm.py +3 -3
  169. classiq/interface/generator/quantum_function_call.py +24 -29
  170. classiq/interface/generator/quantum_program.py +9 -9
  171. classiq/interface/generator/register_role.py +2 -4
  172. classiq/interface/generator/slice_parsing_utils.py +4 -3
  173. classiq/interface/generator/standard_gates/standard_gates.py +3 -3
  174. classiq/interface/generator/state_preparation/bell_state_preparation.py +3 -3
  175. classiq/interface/generator/state_preparation/distributions.py +6 -5
  176. classiq/interface/generator/state_preparation/metrics.py +2 -4
  177. classiq/interface/generator/state_preparation/state_preparation.py +4 -4
  178. classiq/interface/generator/synthesis_metadata/synthesis_execution_data.py +3 -3
  179. classiq/interface/generator/transpiler_basis_gates.py +2 -2
  180. classiq/interface/generator/types/enum_declaration.py +2 -3
  181. classiq/interface/generator/types/qstruct_declaration.py +2 -1
  182. classiq/interface/generator/types/struct_declaration.py +3 -2
  183. classiq/interface/generator/ucc.py +2 -1
  184. classiq/interface/generator/unitary_gate.py +2 -2
  185. classiq/interface/generator/user_defined_function_params.py +1 -1
  186. classiq/interface/generator/validations/flow_graph.py +6 -5
  187. classiq/interface/generator/validations/validator_functions.py +3 -2
  188. classiq/interface/generator/visitor.py +9 -14
  189. classiq/interface/hardware.py +5 -6
  190. classiq/interface/helpers/custom_encoders.py +2 -2
  191. classiq/interface/helpers/custom_pydantic_types.py +8 -9
  192. classiq/interface/helpers/dotdict.py +18 -0
  193. classiq/interface/helpers/hashable_mixin.py +3 -2
  194. classiq/interface/helpers/hashable_pydantic_base_model.py +2 -1
  195. classiq/interface/helpers/pydantic_model_helpers.py +4 -3
  196. classiq/interface/helpers/validation_helpers.py +2 -2
  197. classiq/interface/ide/ide_data.py +11 -15
  198. classiq/interface/ide/visual_model.py +33 -22
  199. classiq/interface/jobs.py +2 -2
  200. classiq/interface/model/bind_operation.py +5 -4
  201. classiq/interface/model/classical_parameter_declaration.py +2 -2
  202. classiq/interface/model/handle_binding.py +3 -2
  203. classiq/interface/model/inplace_binary_operation.py +2 -1
  204. classiq/interface/model/model.py +12 -11
  205. classiq/interface/model/native_function_definition.py +10 -0
  206. classiq/interface/model/port_declaration.py +2 -2
  207. classiq/interface/model/quantum_expressions/amplitude_loading_operation.py +3 -2
  208. classiq/interface/model/quantum_expressions/arithmetic_operation.py +3 -2
  209. classiq/interface/model/quantum_expressions/quantum_expression.py +8 -7
  210. classiq/interface/model/quantum_function_call.py +9 -14
  211. classiq/interface/model/quantum_function_declaration.py +10 -12
  212. classiq/interface/model/quantum_lambda_function.py +3 -16
  213. classiq/interface/model/quantum_statement.py +4 -3
  214. classiq/interface/model/quantum_type.py +5 -5
  215. classiq/interface/model/statement_block.py +2 -3
  216. classiq/interface/model/validation_handle.py +5 -4
  217. classiq/interface/server/global_versions.py +3 -3
  218. classiq/model_expansions/atomic_expression_functions_defs.py +3 -2
  219. classiq/model_expansions/call_to_model_converter.py +190 -0
  220. classiq/model_expansions/capturing/captured_var_manager.py +4 -6
  221. classiq/model_expansions/capturing/propagated_var_stack.py +7 -7
  222. classiq/model_expansions/closure.py +17 -9
  223. classiq/model_expansions/evaluators/arg_type_match.py +3 -2
  224. classiq/model_expansions/evaluators/argument_types.py +3 -3
  225. classiq/model_expansions/evaluators/control.py +3 -3
  226. classiq/model_expansions/evaluators/parameter_types.py +7 -7
  227. classiq/model_expansions/evaluators/quantum_type_utils.py +2 -1
  228. classiq/model_expansions/evaluators/type_type_match.py +1 -1
  229. classiq/model_expansions/expression_evaluator.py +10 -9
  230. classiq/model_expansions/expression_renamer.py +6 -6
  231. classiq/model_expansions/function_builder.py +19 -12
  232. classiq/model_expansions/generative_functions.py +3 -2
  233. classiq/model_expansions/interpreter.py +31 -19
  234. classiq/model_expansions/model_tables.py +14 -14
  235. classiq/model_expansions/quantum_operations/bind.py +2 -4
  236. classiq/model_expansions/quantum_operations/classicalif.py +1 -1
  237. classiq/model_expansions/quantum_operations/control.py +2 -4
  238. classiq/model_expansions/quantum_operations/emitter.py +10 -13
  239. classiq/model_expansions/quantum_operations/expression_operation.py +23 -16
  240. classiq/model_expansions/quantum_operations/inplace_binary_operation.py +164 -38
  241. classiq/model_expansions/quantum_operations/phase.py +6 -6
  242. classiq/model_expansions/quantum_operations/quantum_assignment_operation.py +25 -5
  243. classiq/model_expansions/quantum_operations/quantum_function_call.py +41 -2
  244. classiq/model_expansions/quantum_operations/repeat.py +1 -3
  245. classiq/model_expansions/scope.py +11 -10
  246. classiq/model_expansions/scope_initialization.py +6 -5
  247. classiq/model_expansions/sympy_conversion/expression_to_sympy.py +6 -6
  248. classiq/model_expansions/sympy_conversion/sympy_to_python.py +2 -2
  249. classiq/model_expansions/visitors/variable_references.py +5 -4
  250. classiq/qmod/__init__.py +2 -0
  251. classiq/qmod/builtins/classical_execution_primitives.py +9 -9
  252. classiq/qmod/builtins/functions/__init__.py +75 -53
  253. classiq/qmod/builtins/functions/amplitude_estimation.py +4 -1
  254. classiq/qmod/builtins/functions/arithmetic.py +14 -1
  255. classiq/qmod/builtins/functions/discrete_sine_cosine_transform.py +86 -6
  256. classiq/qmod/builtins/functions/grover.py +41 -45
  257. classiq/qmod/builtins/functions/hea.py +60 -4
  258. classiq/qmod/builtins/functions/linear_pauli_rotation.py +26 -4
  259. classiq/qmod/builtins/functions/modular_exponentiation.py +90 -29
  260. classiq/qmod/builtins/functions/operators.py +1 -1
  261. classiq/qmod/builtins/functions/qaoa_penalty.py +14 -5
  262. classiq/qmod/builtins/functions/qft_functions.py +57 -0
  263. classiq/qmod/builtins/functions/qpe.py +20 -4
  264. classiq/qmod/builtins/functions/qsvt.py +49 -4
  265. classiq/qmod/builtins/functions/standard_gates.py +18 -18
  266. classiq/qmod/builtins/functions/state_preparation.py +92 -10
  267. classiq/qmod/builtins/functions/swap_test.py +7 -1
  268. classiq/qmod/builtins/functions/utility_functions.py +43 -0
  269. classiq/qmod/builtins/functions/variational.py +53 -0
  270. classiq/qmod/builtins/operations.py +4 -5
  271. classiq/qmod/cfunc.py +2 -2
  272. classiq/qmod/classical_function.py +3 -7
  273. classiq/qmod/create_model_function.py +19 -8
  274. classiq/qmod/declaration_inferrer.py +7 -10
  275. classiq/qmod/expression_query.py +3 -3
  276. classiq/qmod/generative.py +2 -1
  277. classiq/qmod/model_state_container.py +5 -7
  278. classiq/qmod/native/__init__.py +1 -3
  279. classiq/qmod/native/expression_to_qmod.py +9 -8
  280. classiq/qmod/native/pretty_printer.py +6 -5
  281. classiq/qmod/pretty_print/__init__.py +1 -3
  282. classiq/qmod/pretty_print/expression_to_python.py +13 -12
  283. classiq/qmod/pretty_print/pretty_printer.py +13 -12
  284. classiq/qmod/python_classical_type.py +8 -4
  285. classiq/qmod/qfunc.py +4 -4
  286. classiq/qmod/qmod_parameter.py +3 -1
  287. classiq/qmod/qmod_variable.py +11 -10
  288. classiq/qmod/quantum_expandable.py +32 -15
  289. classiq/qmod/quantum_function.py +34 -5
  290. classiq/qmod/semantics/annotation.py +1 -1
  291. classiq/qmod/semantics/error_manager.py +8 -7
  292. classiq/qmod/semantics/static_semantics_visitor.py +19 -24
  293. classiq/qmod/semantics/validation/constants_validation.py +1 -1
  294. classiq/qmod/semantics/validation/func_call_validation.py +2 -2
  295. classiq/qmod/semantics/validation/main_validation.py +33 -0
  296. classiq/qmod/semantics/validation/types_validation.py +2 -1
  297. classiq/qmod/symbolic.py +5 -8
  298. classiq/qmod/symbolic_type.py +2 -2
  299. classiq/qmod/synthesize_separately.py +16 -0
  300. {classiq-0.52.0.dist-info → classiq-0.54.0.dist-info}/METADATA +1 -1
  301. {classiq-0.52.0.dist-info → classiq-0.54.0.dist-info}/RECORD +302 -295
  302. classiq/qmod/builtins/functions/qft.py +0 -23
  303. {classiq-0.52.0.dist-info → classiq-0.54.0.dist-info}/WHEEL +0 -0
@@ -1,12 +1,14 @@
1
1
  from collections import defaultdict
2
+ from collections.abc import Sequence
2
3
  from dataclasses import dataclass, field
3
4
  from functools import cached_property
4
- from typing import Any, Dict, List, Optional, Sequence, Set, Union
5
+ from typing import Any, Optional, Union
5
6
 
6
7
  from typing_extensions import Self
7
8
 
8
9
  from classiq.interface.exceptions import ClassiqInternalExpansionError
9
10
  from classiq.interface.generator.visitor import Visitor
11
+ from classiq.interface.model.native_function_definition import FunctionSynthesisData
10
12
  from classiq.interface.model.port_declaration import PortDeclaration
11
13
  from classiq.interface.model.quantum_function_call import QuantumFunctionCall
12
14
  from classiq.interface.model.quantum_function_declaration import (
@@ -27,12 +29,12 @@ from classiq.qmod.quantum_function import GenerativeQFunc
27
29
  @dataclass(frozen=True)
28
30
  class Closure:
29
31
  name: str
30
- blocks: Dict[str, Sequence[QuantumStatement]]
32
+ blocks: dict[str, Sequence[QuantumStatement]]
31
33
  scope: Scope
32
34
  positional_arg_declarations: Sequence[PositionalArg] = tuple()
33
35
 
34
- @cached_property
35
- def port_declarations(self) -> Dict[str, PortDeclaration]:
36
+ @property
37
+ def port_declarations(self) -> dict[str, PortDeclaration]:
36
38
  return {
37
39
  param.name: param
38
40
  for param in self.positional_arg_declarations
@@ -42,7 +44,7 @@ class Closure:
42
44
 
43
45
  @dataclass(frozen=True)
44
46
  class GenerativeClosure(Closure):
45
- generative_blocks: Dict[str, GenerativeQFunc] = None # type:ignore[assignment]
47
+ generative_blocks: dict[str, GenerativeQFunc] = None # type:ignore[assignment]
46
48
 
47
49
 
48
50
  @dataclass(frozen=True)
@@ -50,6 +52,7 @@ class FunctionClosure(Closure):
50
52
  is_lambda: bool = False
51
53
  is_atomic: bool = False
52
54
  signature_scope: Scope = field(default_factory=Scope)
55
+ synthesis_data: FunctionSynthesisData = field(default_factory=FunctionSynthesisData)
53
56
 
54
57
  @property
55
58
  def body(self) -> Sequence[QuantumStatement]:
@@ -59,7 +62,7 @@ class FunctionClosure(Closure):
59
62
  return self.blocks["body"]
60
63
 
61
64
  @cached_property
62
- def colliding_variables(self) -> Set[str]:
65
+ def colliding_variables(self) -> set[str]:
63
66
  # Note that this has to be accessed after adding the parameters from the signature and not during
64
67
  # initialization
65
68
  return VariableCollector(self.scope).get_colliding_variables(self.body)
@@ -74,6 +77,7 @@ class FunctionClosure(Closure):
74
77
  expr_renamer: Optional[ExpressionRenamer] = None,
75
78
  is_lambda: bool = False,
76
79
  is_atomic: bool = False,
80
+ synthesis_data: Optional[FunctionSynthesisData] = None,
77
81
  **kwargs: Any,
78
82
  ) -> Self:
79
83
  if expr_renamer:
@@ -86,6 +90,9 @@ class FunctionClosure(Closure):
86
90
  body = expr_renamer.visit(body)
87
91
 
88
92
  blocks = {"body": body} if body is not None else {}
93
+ synthesis_data = (
94
+ synthesis_data if synthesis_data is not None else FunctionSynthesisData()
95
+ )
89
96
  return cls(
90
97
  name,
91
98
  blocks,
@@ -93,6 +100,7 @@ class FunctionClosure(Closure):
93
100
  positional_arg_declarations,
94
101
  is_lambda,
95
102
  is_atomic,
103
+ synthesis_data=synthesis_data,
96
104
  **kwargs,
97
105
  )
98
106
 
@@ -110,19 +118,19 @@ class GenerativeFunctionClosure(GenerativeClosure, FunctionClosure):
110
118
  pass
111
119
 
112
120
 
113
- NestedFunctionClosureT = Union[FunctionClosure, List["NestedFunctionClosureT"]]
121
+ NestedFunctionClosureT = Union[FunctionClosure, list["NestedFunctionClosureT"]]
114
122
 
115
123
 
116
124
  class VariableCollector(Visitor):
117
125
  def __init__(self, function_scope: Scope) -> None:
118
126
  self._function_scope = function_scope
119
- self._variables: defaultdict[str, Set[Optional[str]]] = defaultdict(set)
127
+ self._variables: defaultdict[str, set[Optional[str]]] = defaultdict(set)
120
128
  for var in self._function_scope.data:
121
129
  defining_function = self._function_scope[var].defining_function
122
130
  if defining_function is not None:
123
131
  self._variables[var].add(defining_function.name)
124
132
 
125
- def get_colliding_variables(self, body: Sequence[QuantumStatement]) -> Set[str]:
133
+ def get_colliding_variables(self, body: Sequence[QuantumStatement]) -> set[str]:
126
134
  self.visit(body)
127
135
  return {
128
136
  var
@@ -1,5 +1,6 @@
1
+ from collections.abc import Sequence
1
2
  from enum import Enum
2
- from typing import Any, List, Sequence
3
+ from typing import Any
3
4
 
4
5
  from classiq.interface.exceptions import ClassiqExpansionError
5
6
  from classiq.interface.generator.expressions.qmod_sized_proxy import QmodSizedProxy
@@ -31,7 +32,7 @@ from classiq.qmod.qmod_parameter import CInt, get_qmod_type
31
32
 
32
33
  def check_type_match(
33
34
  parameters: Sequence[AnonPositionalArg],
34
- arguments: List[Evaluated],
35
+ arguments: list[Evaluated],
35
36
  function_name: str,
36
37
  ) -> None:
37
38
  if len(parameters) != len(arguments):
@@ -1,4 +1,4 @@
1
- from typing import List, Sequence
1
+ from collections.abc import Sequence
2
2
 
3
3
  from classiq.interface.generator.functions.port_declaration import (
4
4
  PortDeclarationDirection,
@@ -12,8 +12,8 @@ from classiq.model_expansions.scope import Evaluated, QuantumSymbol
12
12
 
13
13
  def add_information_from_output_arguments(
14
14
  parameters: Sequence[AnonPositionalArg],
15
- args: List[Evaluated],
16
- ) -> List[Evaluated]:
15
+ args: list[Evaluated],
16
+ ) -> list[Evaluated]:
17
17
  """
18
18
  This function propagates the quantum type information from the output arguments
19
19
  to the arguments that were passed to it.
@@ -1,4 +1,4 @@
1
- from typing import Any, Tuple
1
+ from typing import Any
2
2
 
3
3
  from sympy import Equality
4
4
  from sympy.core.numbers import Number
@@ -19,7 +19,7 @@ def type_name(obj: Any) -> str:
19
19
  return type(obj).__name__
20
20
 
21
21
 
22
- def resolve_num_condition(condition: Equality) -> Tuple[QmodSizedProxy, str]:
22
+ def resolve_num_condition(condition: Equality) -> tuple[QmodSizedProxy, str]:
23
23
  ctrl, ctrl_val = condition.args
24
24
  if isinstance(ctrl, Number) and isinstance(ctrl_val, QmodQScalarProxy):
25
25
  ctrl, ctrl_val = ctrl_val, ctrl
@@ -41,7 +41,7 @@ def _calculate_ctrl_state(ctrl: QmodSizedProxy, ctrl_val: float) -> str:
41
41
  return _to_twos_complement(integer_ctrl_val, ctrl.size)
42
42
 
43
43
 
44
- def _get_numeric_attributes(ctrl: QmodSizedProxy) -> Tuple[bool, int]:
44
+ def _get_numeric_attributes(ctrl: QmodSizedProxy) -> tuple[bool, int]:
45
45
  return (
46
46
  (ctrl.is_signed, ctrl.fraction_digits)
47
47
  if isinstance(ctrl, QmodQNumProxy)
@@ -1,4 +1,4 @@
1
- from typing import List, Set, Union
1
+ from typing import Union
2
2
 
3
3
  from classiq.interface.exceptions import (
4
4
  ClassiqExpansionError,
@@ -41,8 +41,8 @@ from classiq.model_expansions.scope import Evaluated, QuantumSymbol, Scope
41
41
 
42
42
 
43
43
  def evaluate_parameter_types_from_args(
44
- closure: FunctionClosure, signature_scope: Scope, arguments: List[Evaluated]
45
- ) -> List[PositionalArg]:
44
+ closure: FunctionClosure, signature_scope: Scope, arguments: list[Evaluated]
45
+ ) -> list[PositionalArg]:
46
46
  parameters = closure.positional_arg_declarations
47
47
  function_name = closure.name
48
48
  check_type_match(parameters, arguments, function_name)
@@ -90,12 +90,12 @@ def _update_scope(
90
90
  )
91
91
 
92
92
 
93
- NestedFunctionClosureT = Union[FunctionClosure, List["NestedFunctionClosureT"]]
93
+ NestedFunctionClosureT = Union[FunctionClosure, list["NestedFunctionClosureT"]]
94
94
 
95
95
 
96
96
  def _update_operand_signature_environment(
97
97
  operand_val: NestedFunctionClosureT,
98
- parameter_names: Set[str],
98
+ parameter_names: set[str],
99
99
  closure: FunctionClosure,
100
100
  ) -> None:
101
101
  # We update the environment (parent) of the operand by adding closure.scope.data,
@@ -203,8 +203,8 @@ def _evaluate_qstruct_in_quantum_symbol(
203
203
 
204
204
 
205
205
  def evaluate_types_in_quantum_symbols(
206
- symbols: List[QuantumSymbol], scope: Scope
207
- ) -> List[QuantumSymbol]:
206
+ symbols: list[QuantumSymbol], scope: Scope
207
+ ) -> list[QuantumSymbol]:
208
208
  return [
209
209
  QuantumSymbol(
210
210
  handle=symbol.handle,
@@ -1,4 +1,5 @@
1
- from typing import Mapping, Optional
1
+ from collections.abc import Mapping
2
+ from typing import Optional
2
3
 
3
4
  from classiq.interface.exceptions import (
4
5
  ClassiqExpansionError,
@@ -1,4 +1,4 @@
1
- from typing import Sequence
1
+ from collections.abc import Sequence
2
2
 
3
3
  from classiq.interface.exceptions import (
4
4
  ClassiqExpansionError,
@@ -1,6 +1,7 @@
1
1
  import ast
2
+ from collections.abc import Mapping
2
3
  from enum import EnumMeta
3
- from typing import Any, Dict, List, Mapping, Optional, Set
4
+ from typing import Any, Optional
4
5
 
5
6
  from sympy import sympify
6
7
 
@@ -30,14 +31,14 @@ from classiq.model_expansions.sympy_conversion.sympy_to_python import sympy_to_p
30
31
  from classiq.qmod import symbolic
31
32
 
32
33
 
33
- def evaluate_constants(constants: List[Constant]) -> Dict[str, EvaluatedExpression]:
34
- result: Dict[str, EvaluatedExpression] = {}
34
+ def evaluate_constants(constants: list[Constant]) -> dict[str, EvaluatedExpression]:
35
+ result: dict[str, EvaluatedExpression] = {}
35
36
  for constant in constants:
36
37
  result[constant.name] = evaluate(constant.value, result)
37
38
  return result
38
39
 
39
40
 
40
- def evaluate_constants_as_python(constants: List[Constant]) -> Dict[str, Any]:
41
+ def evaluate_constants_as_python(constants: list[Constant]) -> dict[str, Any]:
41
42
  evaluated = evaluate_constants(constants)
42
43
  return {
43
44
  constant.name: qmod_val_to_python(
@@ -50,9 +51,9 @@ def evaluate_constants_as_python(constants: List[Constant]) -> Dict[str, Any]:
50
51
  def evaluate(
51
52
  expr: Expression,
52
53
  locals_dict: Mapping[str, EvaluatedExpression],
53
- uninitialized_locals: Optional[Set[str]] = None,
54
+ uninitialized_locals: Optional[set[str]] = None,
54
55
  ) -> EvaluatedExpression:
55
- model_locals: Dict[str, ExpressionValue] = {}
56
+ model_locals: dict[str, ExpressionValue] = {}
56
57
  model_locals.update(ATOMIC_EXPRESSION_FUNCTIONS)
57
58
  model_locals.update(SymbolTable.enum_table.enums)
58
59
  # locals override builtin-functions
@@ -81,8 +82,8 @@ def evaluate(
81
82
 
82
83
  def _validate_undefined_vars(
83
84
  expr: str,
84
- model_locals: Dict[str, ExpressionValue],
85
- uninitialized_locals: Optional[Set[str]],
85
+ model_locals: dict[str, ExpressionValue],
86
+ uninitialized_locals: Optional[set[str]],
86
87
  ) -> None:
87
88
  uninitialized_locals = uninitialized_locals or set()
88
89
  id_visitor = _VarsCollector()
@@ -110,7 +111,7 @@ def _validate_undefined_vars(
110
111
 
111
112
  class _VarsCollector(ast.NodeTransformer):
112
113
  def __init__(self) -> None:
113
- self.vars: Set[str] = set()
114
+ self.vars: set[str] = set()
114
115
 
115
116
  def visit_Name(self, node: ast.Name) -> None:
116
117
  self.vars.add(node.id)
@@ -1,5 +1,5 @@
1
1
  import ast
2
- from typing import Dict, Sequence
2
+ from collections.abc import Sequence
3
3
 
4
4
  from classiq.interface.generator.expressions.expression import Expression
5
5
  from classiq.interface.generator.expressions.expression_constants import (
@@ -17,11 +17,11 @@ from classiq.model_expansions.visitors.variable_references import VarRefTransfor
17
17
 
18
18
  class ExpressionRenamer(Transformer):
19
19
 
20
- def __init__(self, var_mapping: Dict[str, str]) -> None:
20
+ def __init__(self, var_mapping: dict[str, str]) -> None:
21
21
  self.var_ref_transformer = VarRefTransformer(var_mapping)
22
22
 
23
23
  @property
24
- def var_mapping(self) -> Dict[str, str]:
24
+ def var_mapping(self) -> dict[str, str]:
25
25
  return self.var_ref_transformer.var_mapping
26
26
 
27
27
  def visit_QuantumFunctionCall(
@@ -41,8 +41,8 @@ class ExpressionRenamer(Transformer):
41
41
  return self.var_mapping.get(name, name)
42
42
 
43
43
  def rename_expression_dict(
44
- self, expr_dict: Dict[str, Expression]
45
- ) -> Dict[str, Expression]:
44
+ self, expr_dict: dict[str, Expression]
45
+ ) -> dict[str, Expression]:
46
46
  return {
47
47
  self.rename_string(key): self.visit(val) for key, val in expr_dict.items()
48
48
  }
@@ -51,7 +51,7 @@ class ExpressionRenamer(Transformer):
51
51
  def from_positional_arg_declarations(
52
52
  cls, positional_arg_declarations: Sequence[PositionalArg], suffix: str
53
53
  ) -> "ExpressionRenamer":
54
- var_mapping: Dict[str, str] = dict()
54
+ var_mapping: dict[str, str] = dict()
55
55
  for arg in positional_arg_declarations:
56
56
  if not isinstance(arg, ClassicalParameterDeclaration):
57
57
  continue
@@ -1,6 +1,7 @@
1
+ from collections.abc import Iterable, Iterator, Sequence
1
2
  from contextlib import contextmanager
2
3
  from dataclasses import dataclass, field
3
- from typing import Dict, Generic, Iterable, Iterator, List, Optional, Sequence, TypeVar
4
+ from typing import Generic, Optional, TypeVar
4
5
 
5
6
  from classiq.interface.exceptions import (
6
7
  ClassiqExpansionError,
@@ -18,6 +19,7 @@ from classiq.interface.generator.functions.port_declaration import (
18
19
  )
19
20
  from classiq.interface.model.model import MAIN_FUNCTION_NAME
20
21
  from classiq.interface.model.native_function_definition import (
22
+ FunctionSynthesisData,
21
23
  NativeFunctionDefinition,
22
24
  )
23
25
  from classiq.interface.model.port_declaration import PortDeclaration
@@ -35,14 +37,14 @@ ClosureType = TypeVar("ClosureType", bound=Closure)
35
37
 
36
38
  @dataclass
37
39
  class Block:
38
- statements: List[QuantumStatement] = field(default_factory=list)
39
- captured_vars: List[PortDeclaration] = field(default_factory=list)
40
+ statements: list[QuantumStatement] = field(default_factory=list)
41
+ captured_vars: list[PortDeclaration] = field(default_factory=list)
40
42
 
41
43
 
42
44
  @dataclass
43
45
  class OperationContext(Generic[ClosureType]):
44
46
  closure: ClosureType
45
- blocks: Dict[str, Block] = field(default_factory=dict)
47
+ blocks: dict[str, Block] = field(default_factory=dict)
46
48
 
47
49
  @property
48
50
  def name(self) -> str:
@@ -52,7 +54,7 @@ class OperationContext(Generic[ClosureType]):
52
54
  def positional_arg_declarations(self) -> Sequence[PositionalArg]:
53
55
  return self.closure.positional_arg_declarations
54
56
 
55
- def statements(self, block_name: str) -> List[QuantumStatement]:
57
+ def statements(self, block_name: str) -> list[QuantumStatement]:
56
58
  return self.blocks[block_name].statements
57
59
 
58
60
 
@@ -63,22 +65,26 @@ class FunctionContext(OperationContext[FunctionClosure]):
63
65
  return cls(original_function, {"body": Block()})
64
66
 
65
67
  @property
66
- def body(self) -> List[QuantumStatement]:
68
+ def body(self) -> list[QuantumStatement]:
67
69
  return self.statements("body")
68
70
 
69
71
  @property
70
- def captured_vars(self) -> List[PortDeclaration]:
72
+ def captured_vars(self) -> list[PortDeclaration]:
71
73
  return self.blocks["body"].captured_vars
72
74
 
73
75
  @property
74
76
  def is_lambda(self) -> bool:
75
77
  return self.closure.is_lambda
76
78
 
79
+ @property
80
+ def synthesis_data(self) -> FunctionSynthesisData:
81
+ return self.closure.synthesis_data
82
+
77
83
 
78
84
  class OperationBuilder:
79
85
  def __init__(self) -> None:
80
- self._operations: List[OperationContext] = []
81
- self._blocks: List[str] = []
86
+ self._operations: list[OperationContext] = []
87
+ self._blocks: list[str] = []
82
88
  self._counter = 0
83
89
 
84
90
  @property
@@ -93,7 +99,7 @@ class OperationBuilder:
93
99
  raise ClassiqInternalExpansionError("No function found")
94
100
 
95
101
  @property
96
- def _current_statements(self) -> List[QuantumStatement]:
102
+ def _current_statements(self) -> list[QuantumStatement]:
97
103
  return self._operations[-1].blocks[self._blocks[-1]].statements
98
104
 
99
105
  def emit_statement(self, statement: QuantumStatement) -> None:
@@ -160,7 +166,7 @@ class OperationBuilder:
160
166
  name = f"{name}_{LAMBDA_KEYWORD + '_0_0_' if function_context.is_lambda else ''}{EXPANDED_KEYWORD}_{self._counter}"
161
167
  self._counter += 1
162
168
 
163
- new_parameters: List[PortDeclaration] = [
169
+ new_parameters: list[PortDeclaration] = [
164
170
  param
165
171
  for param in function_context.positional_arg_declarations
166
172
  if isinstance(param, PortDeclaration)
@@ -170,10 +176,11 @@ class OperationBuilder:
170
176
  name=name,
171
177
  body=function_context.body,
172
178
  positional_arg_declarations=new_parameters,
179
+ synthesis_data=function_context.synthesis_data,
173
180
  )
174
181
 
175
182
 
176
- def validate_captured_vars(captured_vars: List[PortDeclaration]) -> None:
183
+ def validate_captured_vars(captured_vars: list[PortDeclaration]) -> None:
177
184
  if input_captured := [
178
185
  demangle_name(var.name)
179
186
  for var in captured_vars
@@ -1,4 +1,5 @@
1
- from typing import TYPE_CHECKING, Any, List, Mapping
1
+ from collections.abc import Mapping
2
+ from typing import TYPE_CHECKING, Any
2
3
 
3
4
  from classiq.interface.exceptions import ClassiqInternalExpansionError
4
5
  from classiq.interface.generator.expressions.qmod_struct_instance import (
@@ -127,7 +128,7 @@ class _InterpreterExpandable(QFunc):
127
128
  def emit_generative_statements(
128
129
  interpreter: "Interpreter",
129
130
  operation: GenerativeClosure,
130
- args: List[Evaluated],
131
+ args: list[Evaluated],
131
132
  ) -> None:
132
133
  python_qmod_args = [
133
134
  translate_ast_arg_to_python_qmod(param, arg)
@@ -1,7 +1,8 @@
1
1
  import copy
2
+ from collections.abc import Iterator, Sequence
2
3
  from contextlib import contextmanager, nullcontext
3
4
  from functools import singledispatchmethod
4
- from typing import Any, Iterator, List, Optional, Sequence, Tuple, Type, cast
5
+ from typing import Any, Optional, cast
5
6
 
6
7
  import numpy as np
7
8
  from numpy.random import permutation
@@ -45,6 +46,7 @@ from classiq.interface.model.variable_declaration_statement import (
45
46
  )
46
47
  from classiq.interface.model.within_apply_operation import WithinApply
47
48
 
49
+ from classiq.model_expansions.call_to_model_converter import BlockFunctionInfo
48
50
  from classiq.model_expansions.capturing.propagated_var_stack import PropagatedVarStack
49
51
  from classiq.model_expansions.closure import (
50
52
  Closure,
@@ -88,7 +90,7 @@ from classiq.qmod.builtins.functions import permute
88
90
  from classiq.qmod.quantum_function import GenerativeQFunc
89
91
  from classiq.qmod.semantics.error_manager import ErrorManager
90
92
 
91
- STATEMENT_TYPES_FOR_SOURCE_REFERENCE_PROPAGATION: Tuple[Type[QuantumStatement], ...] = (
93
+ STATEMENT_TYPES_FOR_SOURCE_REFERENCE_PROPAGATION: tuple[type[QuantumStatement], ...] = (
92
94
  QuantumFunctionCall,
93
95
  VariableDeclarationStatement,
94
96
  QuantumAssignmentOperation,
@@ -99,14 +101,14 @@ class Interpreter:
99
101
  def __init__(
100
102
  self,
101
103
  model: Model,
102
- generative_functions: Optional[List[GenerativeQFunc]] = None,
104
+ generative_functions: Optional[list[GenerativeQFunc]] = None,
103
105
  is_frontend: bool = False,
104
106
  ) -> None:
105
107
  self._is_frontend = is_frontend
106
108
  self._model = model
107
109
  self._current_scope = Scope()
108
110
  self._builder = OperationBuilder()
109
- self._expanded_functions: List[NativeFunctionDefinition] = []
111
+ self._expanded_functions: list[NativeFunctionDefinition] = []
110
112
  self._propagated_var_stack = PropagatedVarStack(
111
113
  self._current_scope, self._builder
112
114
  )
@@ -120,6 +122,7 @@ class Interpreter:
120
122
 
121
123
  self._counted_name_allocator = CountedNameAllocator()
122
124
  self._error_manager: ErrorManager = ErrorManager()
125
+ self._synthesized_separately_blocks: dict[str, BlockFunctionInfo] = {}
123
126
 
124
127
  @contextmanager
125
128
  def _scope_guard(self, scope: Scope) -> Iterator[None]:
@@ -154,9 +157,10 @@ class Interpreter:
154
157
  self._builder.create_definition(cast(FunctionContext, context))
155
158
  )
156
159
 
157
- def expand(self) -> Model:
160
+ def expand(self) -> tuple[Model, dict[str, BlockFunctionInfo]]:
158
161
  try:
159
162
  with self._error_manager.call("main"):
163
+ self._synthesized_separately_blocks = {}
160
164
  self._expand_main_func()
161
165
  except Exception as e:
162
166
  if isinstance(e, ClassiqInternalExpansionError) or debug_mode.get():
@@ -168,17 +172,20 @@ class Interpreter:
168
172
  finally:
169
173
  self._error_manager.report_errors(ClassiqExpansionError)
170
174
 
171
- return Model(
172
- constraints=self._model.constraints,
173
- preferences=self._model.preferences,
174
- classical_execution_code=self._model.classical_execution_code,
175
- execution_preferences=self._model.execution_preferences,
176
- functions=self._expanded_functions,
177
- constants=self._model.constants,
178
- enums=self._model.enums,
179
- types=self._model.types,
180
- qstructs=self._model.qstructs,
181
- debug_info=self._model.debug_info,
175
+ return (
176
+ Model(
177
+ constraints=self._model.constraints,
178
+ preferences=self._model.preferences,
179
+ classical_execution_code=self._model.classical_execution_code,
180
+ execution_preferences=self._model.execution_preferences,
181
+ functions=self._expanded_functions,
182
+ constants=self._model.constants,
183
+ enums=self._model.enums,
184
+ types=self._model.types,
185
+ qstructs=self._model.qstructs,
186
+ debug_info=self._model.debug_info,
187
+ ),
188
+ self._synthesized_separately_blocks,
182
189
  )
183
190
 
184
191
  @singledispatchmethod
@@ -196,7 +203,7 @@ class Interpreter:
196
203
  @evaluate.register
197
204
  def evaluate_lambda(self, function: QuantumLambdaFunction) -> Evaluated:
198
205
  renamed_params = [
199
- param.rename(function.get_rename_params()[idx])
206
+ param.rename(function.pos_rename_params[idx])
200
207
  for idx, param in enumerate(function.func_decl.positional_arg_declarations)
201
208
  ]
202
209
  func_decl = NamedParamsQuantumFunctionDeclaration(
@@ -204,7 +211,7 @@ class Interpreter:
204
211
  positional_arg_declarations=renamed_params,
205
212
  )
206
213
 
207
- closure_class: Type[FunctionClosure]
214
+ closure_class: type[FunctionClosure]
208
215
  extra_args: dict[str, Any]
209
216
  if function.is_generative():
210
217
  closure_class = GenerativeFunctionClosure
@@ -339,7 +346,12 @@ class Interpreter:
339
346
 
340
347
  def _expand_operation(self, operation: Closure) -> OperationContext:
341
348
  with self._builder.operation_context(operation) as context:
342
- if isinstance(operation, FunctionClosure) and operation.name == "permute":
349
+ if (
350
+ isinstance(operation, FunctionClosure)
351
+ and operation.synthesis_data.should_synthesize_separately
352
+ ):
353
+ pass
354
+ elif isinstance(operation, FunctionClosure) and operation.name == "permute":
343
355
  # special expansion since permute is generative
344
356
  with self._scope_guard(operation.scope):
345
357
  self._expand_permute()
@@ -1,6 +1,6 @@
1
1
  from abc import ABC, abstractmethod
2
2
  from enum import IntEnum
3
- from typing import ClassVar, Dict, Generic, List, Optional, TypeVar
3
+ from typing import ClassVar, Generic, Optional, TypeVar
4
4
 
5
5
  from classiq.interface.generator.expressions.handle_identifier import HandleIdentifier
6
6
  from classiq.interface.generator.functions.classical_type import QmodPyObject
@@ -18,15 +18,15 @@ DeclarationType = TypeVar(
18
18
 
19
19
 
20
20
  class TypeTable(Generic[DeclarationType], ABC):
21
- def __init__(self, user_types: List[DeclarationType]) -> None:
22
- self._all_types: Dict[str, DeclarationType] = self.builtins.copy()
21
+ def __init__(self, user_types: list[DeclarationType]) -> None:
22
+ self._all_types: dict[str, DeclarationType] = self.builtins.copy()
23
23
  for t in user_types:
24
24
  assert t.name not in self._all_types # FIXME: issue user error (CAD-7856)
25
25
  self._all_types[t.name] = t
26
26
 
27
27
  @property
28
28
  @abstractmethod
29
- def builtins(self) -> Dict[str, DeclarationType]:
29
+ def builtins(self) -> dict[str, DeclarationType]:
30
30
  pass
31
31
 
32
32
  def __getitem__(self, key: str) -> DeclarationType:
@@ -38,20 +38,20 @@ class TypeTable(Generic[DeclarationType], ABC):
38
38
  def __contains__(self, key: str) -> bool:
39
39
  return key in self._all_types
40
40
 
41
- def all_types(self) -> Dict[str, DeclarationType]:
41
+ def all_types(self) -> dict[str, DeclarationType]:
42
42
  return self._all_types
43
43
 
44
44
 
45
45
  class EnumTable(TypeTable[EnumDeclaration]):
46
- def __init__(self, user_types: List[EnumDeclaration]) -> None:
46
+ def __init__(self, user_types: list[EnumDeclaration]) -> None:
47
47
  super().__init__(user_types)
48
48
 
49
49
  @property
50
- def builtins(self) -> Dict[str, EnumDeclaration]:
50
+ def builtins(self) -> dict[str, EnumDeclaration]:
51
51
  return BUILTIN_ENUM_DECLARATIONS
52
52
 
53
53
  @property
54
- def enums(self) -> Dict[str, IntEnum]:
54
+ def enums(self) -> dict[str, IntEnum]:
55
55
  return {
56
56
  enum_decl.name: enum_decl.create_enum()
57
57
  for enum_decl in self.all_types().values()
@@ -60,13 +60,13 @@ class EnumTable(TypeTable[EnumDeclaration]):
60
60
 
61
61
  class StructTable(TypeTable[StructDeclaration]):
62
62
  @property
63
- def builtins(self) -> Dict[str, StructDeclaration]:
63
+ def builtins(self) -> dict[str, StructDeclaration]:
64
64
  return BUILTIN_STRUCT_DECLARATIONS
65
65
 
66
66
 
67
67
  class QStructTable(TypeTable[QStructDeclaration]):
68
68
  @property
69
- def builtins(self) -> Dict[str, QStructDeclaration]:
69
+ def builtins(self) -> dict[str, QStructDeclaration]:
70
70
  return {}
71
71
 
72
72
 
@@ -76,15 +76,15 @@ class SymbolTable:
76
76
  qstruct_table: ClassVar[QStructTable] = QStructTable([])
77
77
 
78
78
  @classmethod
79
- def init_user_enums(cls, user_enums: List[EnumDeclaration]) -> None:
79
+ def init_user_enums(cls, user_enums: list[EnumDeclaration]) -> None:
80
80
  cls.enum_table = EnumTable(user_enums)
81
81
 
82
82
  @classmethod
83
- def init_user_types(cls, user_types: List[StructDeclaration]) -> None:
83
+ def init_user_types(cls, user_types: list[StructDeclaration]) -> None:
84
84
  cls.type_table = StructTable(user_types)
85
85
 
86
86
  @classmethod
87
- def init_user_qstructs(cls, user_qstructs: List[QStructDeclaration]) -> None:
87
+ def init_user_qstructs(cls, user_qstructs: list[QStructDeclaration]) -> None:
88
88
  cls.qstruct_table = QStructTable(user_qstructs)
89
89
  QMODULE.qstruct_decls = {
90
90
  qstruct_decl.name: qstruct_decl for qstruct_decl in user_qstructs
@@ -92,7 +92,7 @@ class SymbolTable:
92
92
 
93
93
 
94
94
  class HandleTable:
95
- _handle_map: Dict[HandleIdentifier, QmodPyObject] = {}
95
+ _handle_map: dict[HandleIdentifier, QmodPyObject] = {}
96
96
 
97
97
  @classmethod
98
98
  def get_handle_object(cls, hid: HandleIdentifier) -> Optional[QmodPyObject]: