classiq 0.92.0__py3-none-any.whl → 0.94.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.

Potentially problematic release.


This version of classiq might be problematic. Click here for more details.

Files changed (264) hide show
  1. classiq/__init__.py +6 -19
  2. classiq/_analyzer_extras/_ipywidgets_async_extension.py +7 -7
  3. classiq/_analyzer_extras/interactive_hardware.py +19 -12
  4. classiq/_internals/api_wrapper.py +38 -52
  5. classiq/_internals/async_utils.py +4 -7
  6. classiq/_internals/authentication/auth0.py +3 -3
  7. classiq/_internals/authentication/device.py +4 -4
  8. classiq/_internals/authentication/password_manager.py +13 -13
  9. classiq/_internals/authentication/token_manager.py +4 -5
  10. classiq/_internals/client.py +17 -44
  11. classiq/_internals/config.py +1 -2
  12. classiq/_internals/help.py +1 -2
  13. classiq/_internals/host_checker.py +3 -3
  14. classiq/_internals/jobs.py +14 -14
  15. classiq/_internals/type_validation.py +3 -3
  16. classiq/analyzer/analyzer.py +18 -18
  17. classiq/analyzer/rb.py +17 -8
  18. classiq/applications/chemistry/__init__.py +0 -30
  19. classiq/applications/chemistry/op_utils.py +4 -4
  20. classiq/applications/chemistry/problems.py +3 -3
  21. classiq/applications/chemistry/ucc.py +1 -2
  22. classiq/applications/chemistry/z2_symmetries.py +4 -4
  23. classiq/applications/combinatorial_helpers/allowed_constraints.py +1 -3
  24. classiq/applications/combinatorial_helpers/arithmetic/arithmetic_expression.py +2 -1
  25. classiq/applications/combinatorial_helpers/combinatorial_problem_utils.py +2 -2
  26. classiq/applications/combinatorial_helpers/encoding_mapping.py +2 -3
  27. classiq/applications/combinatorial_helpers/encoding_utils.py +2 -2
  28. classiq/applications/combinatorial_helpers/optimization_model.py +3 -4
  29. classiq/applications/combinatorial_helpers/pauli_helpers/pauli_sparsing.py +2 -2
  30. classiq/applications/combinatorial_helpers/pyomo_utils.py +8 -8
  31. classiq/applications/combinatorial_helpers/sympy_utils.py +1 -3
  32. classiq/applications/combinatorial_helpers/transformations/encoding.py +3 -3
  33. classiq/applications/combinatorial_helpers/transformations/fixed_variables.py +1 -2
  34. classiq/applications/combinatorial_optimization/combinatorial_optimization_config.py +2 -3
  35. classiq/applications/combinatorial_optimization/combinatorial_optimization_model_constructor.py +4 -6
  36. classiq/applications/combinatorial_optimization/combinatorial_problem.py +15 -10
  37. classiq/applications/hamiltonian/pauli_decomposition.py +6 -4
  38. classiq/applications/iqae/iqae.py +8 -8
  39. classiq/applications/qnn/datasets/dataset_base_classes.py +6 -6
  40. classiq/applications/qnn/datasets/dataset_parity.py +6 -6
  41. classiq/applications/qnn/qlayer.py +8 -7
  42. classiq/applications/qnn/torch_utils.py +3 -4
  43. classiq/applications/qnn/types.py +2 -1
  44. classiq/applications/qsp/qsp.py +6 -5
  45. classiq/applications/qsvm/qsvm_data_generation.py +1 -2
  46. classiq/evaluators/classical_expression.py +0 -4
  47. classiq/evaluators/parameter_types.py +17 -12
  48. classiq/evaluators/qmod_annotated_expression.py +24 -26
  49. classiq/evaluators/qmod_expression_visitors/qmod_expression_evaluator.py +14 -14
  50. classiq/evaluators/qmod_expression_visitors/qmod_expression_simplifier.py +2 -1
  51. classiq/evaluators/qmod_expression_visitors/sympy_wrappers.py +8 -8
  52. classiq/evaluators/qmod_node_evaluators/classical_function_evaluation.py +4 -4
  53. classiq/evaluators/qmod_node_evaluators/list_evaluation.py +2 -2
  54. classiq/evaluators/qmod_node_evaluators/numeric_attrs_utils.py +3 -3
  55. classiq/evaluators/qmod_node_evaluators/subscript_evaluation.py +9 -9
  56. classiq/evaluators/qmod_node_evaluators/utils.py +6 -6
  57. classiq/evaluators/qmod_type_inference/classical_type_inference.py +9 -10
  58. classiq/evaluators/qmod_type_inference/quantum_type_inference.py +5 -5
  59. classiq/execution/execution_session.py +18 -19
  60. classiq/execution/jobs.py +26 -26
  61. classiq/execution/qnn.py +1 -2
  62. classiq/execution/user_budgets.py +52 -7
  63. classiq/executor.py +1 -3
  64. classiq/interface/_version.py +1 -1
  65. classiq/interface/analyzer/analysis_params.py +4 -4
  66. classiq/interface/analyzer/cytoscape_graph.py +3 -3
  67. classiq/interface/analyzer/result.py +4 -4
  68. classiq/interface/applications/qsvm.py +5 -8
  69. classiq/interface/ast_node.py +3 -3
  70. classiq/interface/backend/backend_preferences.py +16 -16
  71. classiq/interface/backend/ionq/ionq_quantum_program.py +5 -5
  72. classiq/interface/chemistry/ansatz_library.py +3 -5
  73. classiq/interface/chemistry/operator.py +3 -3
  74. classiq/interface/combinatorial_optimization/examples/knapsack.py +2 -4
  75. classiq/interface/combinatorial_optimization/examples/tsp_digraph.py +1 -2
  76. classiq/interface/compression_utils.py +2 -3
  77. classiq/interface/debug_info/debug_info.py +7 -7
  78. classiq/interface/exceptions.py +6 -3
  79. classiq/interface/execution/iqcc.py +1 -3
  80. classiq/interface/execution/primitives.py +6 -6
  81. classiq/interface/executor/estimate_cost.py +1 -1
  82. classiq/interface/executor/execution_preferences.py +3 -5
  83. classiq/interface/executor/execution_request.py +10 -10
  84. classiq/interface/executor/execution_result.py +1 -2
  85. classiq/interface/executor/quantum_code.py +8 -8
  86. classiq/interface/executor/result.py +28 -18
  87. classiq/interface/executor/user_budget.py +2 -3
  88. classiq/interface/executor/vqe_result.py +5 -6
  89. classiq/interface/generator/ansatz_library.py +6 -8
  90. classiq/interface/generator/application_apis/__init__.py +0 -2
  91. classiq/interface/generator/arith/arithmetic.py +2 -2
  92. classiq/interface/generator/arith/arithmetic_arg_type_validator.py +2 -3
  93. classiq/interface/generator/arith/arithmetic_expression_abc.py +4 -5
  94. classiq/interface/generator/arith/arithmetic_expression_parser.py +11 -4
  95. classiq/interface/generator/arith/arithmetic_expression_validator.py +12 -15
  96. classiq/interface/generator/arith/arithmetic_operations.py +4 -6
  97. classiq/interface/generator/arith/arithmetic_param_getters.py +70 -107
  98. classiq/interface/generator/arith/arithmetic_result_builder.py +4 -4
  99. classiq/interface/generator/arith/ast_node_rewrite.py +8 -4
  100. classiq/interface/generator/arith/binary_ops.py +7 -36
  101. classiq/interface/generator/arith/logical_ops.py +2 -3
  102. classiq/interface/generator/arith/number_utils.py +2 -2
  103. classiq/interface/generator/arith/register_user_input.py +2 -2
  104. classiq/interface/generator/arith/unary_ops.py +2 -2
  105. classiq/interface/generator/circuit_code/circuit_code.py +8 -10
  106. classiq/interface/generator/circuit_code/types_and_constants.py +1 -1
  107. classiq/interface/generator/complex_type.py +2 -2
  108. classiq/interface/generator/copy.py +1 -3
  109. classiq/interface/generator/expressions/atomic_expression_functions.py +0 -5
  110. classiq/interface/generator/expressions/evaluated_expression.py +2 -3
  111. classiq/interface/generator/expressions/expression.py +2 -2
  112. classiq/interface/generator/expressions/proxies/classical/classical_array_proxy.py +4 -7
  113. classiq/interface/generator/function_param_list.py +0 -20
  114. classiq/interface/generator/function_params.py +5 -6
  115. classiq/interface/generator/functions/classical_function_declaration.py +2 -2
  116. classiq/interface/generator/functions/classical_type.py +3 -3
  117. classiq/interface/generator/functions/type_modifier.py +0 -14
  118. classiq/interface/generator/functions/type_name.py +2 -2
  119. classiq/interface/generator/generated_circuit_data.py +12 -13
  120. classiq/interface/generator/hamiltonian_evolution/exponentiation.py +2 -4
  121. classiq/interface/generator/hardware/hardware_data.py +8 -8
  122. classiq/interface/generator/hardware_efficient_ansatz.py +8 -8
  123. classiq/interface/generator/mcu.py +3 -3
  124. classiq/interface/generator/mcx.py +3 -3
  125. classiq/interface/generator/model/constraints.py +34 -5
  126. classiq/interface/generator/model/preferences/preferences.py +15 -21
  127. classiq/interface/generator/model/quantum_register.py +7 -10
  128. classiq/interface/generator/noise_properties.py +3 -7
  129. classiq/interface/generator/parameters.py +1 -1
  130. classiq/interface/generator/partitioned_register.py +1 -2
  131. classiq/interface/generator/preferences/qasm_to_qmod_params.py +11 -0
  132. classiq/interface/generator/qsvm.py +2 -2
  133. classiq/interface/generator/quantum_function_call.py +8 -11
  134. classiq/interface/generator/quantum_program.py +12 -15
  135. classiq/interface/generator/range_types.py +3 -3
  136. classiq/interface/generator/slice_parsing_utils.py +4 -5
  137. classiq/interface/generator/standard_gates/standard_gates.py +2 -4
  138. classiq/interface/generator/state_preparation/state_preparation.py +6 -8
  139. classiq/interface/generator/synthesis_execution_parameter.py +1 -3
  140. classiq/interface/generator/synthesis_metadata/synthesis_execution_data.py +2 -3
  141. classiq/interface/generator/transpiler_basis_gates.py +2 -4
  142. classiq/interface/generator/types/builtin_enum_declarations.py +0 -136
  143. classiq/interface/generator/types/compilation_metadata.py +12 -1
  144. classiq/interface/generator/types/enum_declaration.py +2 -1
  145. classiq/interface/generator/validations/flow_graph.py +3 -3
  146. classiq/interface/generator/visitor.py +10 -12
  147. classiq/interface/hardware.py +2 -2
  148. classiq/interface/helpers/classproperty.py +2 -2
  149. classiq/interface/helpers/custom_encoders.py +2 -1
  150. classiq/interface/helpers/custom_pydantic_types.py +1 -1
  151. classiq/interface/helpers/text_utils.py +1 -4
  152. classiq/interface/ide/visual_model.py +5 -5
  153. classiq/interface/jobs.py +3 -3
  154. classiq/interface/model/allocate.py +4 -4
  155. classiq/interface/model/block.py +2 -2
  156. classiq/interface/model/bounds.py +3 -3
  157. classiq/interface/model/control.py +1 -1
  158. classiq/interface/model/inplace_binary_operation.py +2 -2
  159. classiq/interface/model/model.py +4 -4
  160. classiq/interface/model/parameter.py +1 -3
  161. classiq/interface/model/port_declaration.py +1 -1
  162. classiq/interface/model/quantum_expressions/quantum_expression.py +1 -2
  163. classiq/interface/model/quantum_function_call.py +3 -6
  164. classiq/interface/model/quantum_function_declaration.py +1 -0
  165. classiq/interface/model/quantum_lambda_function.py +4 -4
  166. classiq/interface/model/quantum_statement.py +4 -4
  167. classiq/interface/model/quantum_type.py +14 -14
  168. classiq/interface/model/validation_handle.py +2 -3
  169. classiq/interface/model/variable_declaration_statement.py +2 -2
  170. classiq/interface/pretty_print/expression_to_qmod.py +3 -4
  171. classiq/interface/server/routes.py +0 -4
  172. classiq/interface/source_reference.py +3 -4
  173. classiq/model_expansions/arithmetic.py +6 -7
  174. classiq/model_expansions/arithmetic_compute_result_attrs.py +4 -5
  175. classiq/model_expansions/capturing/captured_vars.py +3 -3
  176. classiq/model_expansions/capturing/mangling_utils.py +1 -2
  177. classiq/model_expansions/closure.py +12 -11
  178. classiq/model_expansions/function_builder.py +14 -6
  179. classiq/model_expansions/generative_functions.py +1 -4
  180. classiq/model_expansions/interpreters/base_interpreter.py +2 -6
  181. classiq/model_expansions/interpreters/generative_interpreter.py +8 -4
  182. classiq/model_expansions/quantum_operations/allocate.py +4 -4
  183. classiq/model_expansions/quantum_operations/assignment_result_processor.py +8 -4
  184. classiq/model_expansions/quantum_operations/call_emitter.py +31 -37
  185. classiq/model_expansions/quantum_operations/declarative_call_emitter.py +2 -2
  186. classiq/model_expansions/quantum_operations/emitter.py +3 -5
  187. classiq/model_expansions/quantum_operations/expression_evaluator.py +3 -3
  188. classiq/model_expansions/quantum_operations/skip_control_verifier.py +1 -2
  189. classiq/model_expansions/quantum_operations/variable_decleration.py +61 -29
  190. classiq/model_expansions/scope.py +7 -7
  191. classiq/model_expansions/scope_initialization.py +4 -0
  192. classiq/model_expansions/visitors/symbolic_param_inference.py +3 -3
  193. classiq/model_expansions/visitors/uncomputation_signature_inference.py +317 -0
  194. classiq/model_expansions/visitors/variable_references.py +15 -14
  195. classiq/open_library/functions/__init__.py +6 -0
  196. classiq/open_library/functions/discrete_sine_cosine_transform.py +19 -14
  197. classiq/open_library/functions/grover.py +8 -10
  198. classiq/open_library/functions/modular_exponentiation.py +96 -8
  199. classiq/qmod/__init__.py +5 -2
  200. classiq/qmod/builtins/classical_execution_primitives.py +4 -11
  201. classiq/qmod/builtins/classical_functions.py +1 -42
  202. classiq/qmod/builtins/enums.py +0 -136
  203. classiq/qmod/builtins/functions/__init__.py +0 -13
  204. classiq/qmod/builtins/functions/allocation.py +4 -4
  205. classiq/qmod/builtins/functions/arithmetic.py +22 -27
  206. classiq/qmod/builtins/functions/standard_gates.py +27 -27
  207. classiq/qmod/builtins/operations.py +43 -58
  208. classiq/qmod/builtins/structs.py +2 -58
  209. classiq/qmod/cfunc.py +3 -2
  210. classiq/qmod/classical_function.py +2 -1
  211. classiq/qmod/classical_variable.py +4 -2
  212. classiq/qmod/cparam.py +2 -8
  213. classiq/qmod/create_model_function.py +7 -7
  214. classiq/qmod/declaration_inferrer.py +33 -30
  215. classiq/qmod/model_state_container.py +2 -2
  216. classiq/qmod/native/pretty_printer.py +25 -14
  217. classiq/qmod/pretty_print/expression_to_python.py +5 -3
  218. classiq/qmod/pretty_print/pretty_printer.py +39 -17
  219. classiq/qmod/python_classical_type.py +40 -13
  220. classiq/qmod/qfunc.py +139 -16
  221. classiq/qmod/qmod_constant.py +2 -2
  222. classiq/qmod/qmod_parameter.py +5 -2
  223. classiq/qmod/qmod_variable.py +47 -43
  224. classiq/qmod/quantum_callable.py +18 -13
  225. classiq/qmod/quantum_expandable.py +33 -26
  226. classiq/qmod/quantum_function.py +51 -32
  227. classiq/qmod/semantics/annotation/call_annotation.py +2 -2
  228. classiq/qmod/semantics/error_manager.py +5 -6
  229. classiq/qmod/semantics/lambdas.py +1 -2
  230. classiq/qmod/semantics/validation/types_validation.py +1 -2
  231. classiq/qmod/symbolic.py +2 -4
  232. classiq/qmod/symbolic_expr.py +12 -4
  233. classiq/qmod/utilities.py +13 -10
  234. classiq/qmod/write_qmod.py +3 -4
  235. classiq/quantum_program.py +1 -3
  236. classiq/synthesis.py +11 -7
  237. {classiq-0.92.0.dist-info → classiq-0.94.0.dist-info}/METADATA +38 -37
  238. {classiq-0.92.0.dist-info → classiq-0.94.0.dist-info}/RECORD +240 -261
  239. classiq-0.94.0.dist-info/WHEEL +4 -0
  240. classiq-0.94.0.dist-info/licenses/LICENSE.txt +27 -0
  241. classiq/applications/chemistry/ansatz_parameters.py +0 -29
  242. classiq/applications/chemistry/chemistry_execution_parameters.py +0 -16
  243. classiq/applications/chemistry/chemistry_model_constructor.py +0 -532
  244. classiq/applications/chemistry/ground_state_problem.py +0 -42
  245. classiq/evaluators/qmod_expression_visitors/qmod_expression_bwc.py +0 -129
  246. classiq/interface/chemistry/elements.py +0 -120
  247. classiq/interface/chemistry/fermionic_operator.py +0 -208
  248. classiq/interface/chemistry/ground_state_problem.py +0 -132
  249. classiq/interface/chemistry/ground_state_result.py +0 -8
  250. classiq/interface/chemistry/molecule.py +0 -71
  251. classiq/interface/generator/application_apis/chemistry_declarations.py +0 -69
  252. classiq/interface/generator/application_apis/entangler_declarations.py +0 -29
  253. classiq/interface/generator/chemistry_function_params.py +0 -50
  254. classiq/interface/generator/entangler_params.py +0 -72
  255. classiq/interface/generator/entanglers.py +0 -14
  256. classiq/interface/generator/hartree_fock.py +0 -26
  257. classiq/interface/generator/hva.py +0 -22
  258. classiq/interface/generator/linear_pauli_rotations.py +0 -92
  259. classiq/interface/generator/qft.py +0 -37
  260. classiq/interface/generator/ucc.py +0 -74
  261. classiq/interface/helpers/backward_compatibility.py +0 -9
  262. classiq/model_expansions/transformers/type_modifier_inference.py +0 -392
  263. classiq/qmod/builtins/functions/chemistry.py +0 -123
  264. classiq-0.92.0.dist-info/WHEEL +0 -4
classiq/qmod/qfunc.py CHANGED
@@ -1,6 +1,12 @@
1
- from typing import Callable, Literal, Optional, Union, overload
2
-
3
- from classiq.interface.exceptions import ClassiqInternalError
1
+ import warnings
2
+ from collections.abc import Callable
3
+ from typing import Literal, overload
4
+
5
+ from classiq.interface.exceptions import (
6
+ ClassiqDeprecationWarning,
7
+ ClassiqInternalError,
8
+ ClassiqValueError,
9
+ )
4
10
 
5
11
  from classiq.qmod.global_declarative_switch import get_global_declarative_switch
6
12
  from classiq.qmod.quantum_callable import QCallable
@@ -21,7 +27,9 @@ def qfunc(
21
27
  *,
22
28
  external: Literal[True],
23
29
  synthesize_separately: Literal[False] = False,
24
- unchecked: Optional[list[str]] = None,
30
+ unchecked: list[str] | None = None,
31
+ disable_perm_check: bool = False,
32
+ disable_const_checks: list[str] | bool = False,
25
33
  ) -> Callable[[Callable], ExternalQFunc]: ...
26
34
 
27
35
 
@@ -30,13 +38,19 @@ def qfunc(
30
38
  *,
31
39
  generative: Literal[False],
32
40
  synthesize_separately: bool = False,
33
- unchecked: Optional[list[str]] = None,
41
+ unchecked: list[str] | None = None,
42
+ disable_perm_check: bool = False,
43
+ disable_const_checks: list[str] | bool = False,
34
44
  ) -> Callable[[Callable], QFunc]: ...
35
45
 
36
46
 
37
47
  @overload
38
48
  def qfunc(
39
- *, synthesize_separately: bool, unchecked: Optional[list[str]] = None
49
+ *,
50
+ synthesize_separately: bool,
51
+ unchecked: list[str] | None = None,
52
+ disable_perm_check: bool = False,
53
+ disable_const_checks: list[str] | bool = False,
40
54
  ) -> Callable[[Callable], GenerativeQFunc]: ...
41
55
 
42
56
 
@@ -44,18 +58,113 @@ def qfunc(
44
58
  def qfunc(
45
59
  *,
46
60
  synthesize_separately: bool = False,
47
- unchecked: Optional[list[str]] = None,
61
+ unchecked: list[str] | None = None,
62
+ disable_perm_check: bool = False,
63
+ disable_const_checks: list[str] | bool = False,
48
64
  ) -> Callable[[Callable], GenerativeQFunc]: ...
49
65
 
50
66
 
51
67
  def qfunc(
52
- func: Optional[Callable] = None,
68
+ func: Callable | None = None,
69
+ *,
70
+ external: bool = False,
71
+ generative: bool | None = None,
72
+ synthesize_separately: bool = False,
73
+ unchecked: list[str] | None = None,
74
+ disable_perm_check: bool = False,
75
+ disable_const_checks: list[str] | bool = False,
76
+ ) -> Callable[[Callable], QCallable] | QCallable:
77
+ return _qfunc_inner(
78
+ func=func,
79
+ external=external,
80
+ generative=generative,
81
+ synthesize_separately=synthesize_separately,
82
+ unchecked=unchecked,
83
+ permutation=False,
84
+ disable_perm_check=disable_perm_check,
85
+ disable_const_checks=disable_const_checks,
86
+ )
87
+
88
+
89
+ @overload
90
+ def qperm(func: Callable) -> GenerativeQFunc: ...
91
+
92
+
93
+ @overload
94
+ def qperm(
95
+ *,
96
+ external: Literal[True],
97
+ synthesize_separately: Literal[False] = False,
98
+ unchecked: list[str] | None = None,
99
+ disable_perm_check: bool = False,
100
+ disable_const_checks: list[str] | bool = False,
101
+ ) -> Callable[[Callable], ExternalQFunc]: ...
102
+
103
+
104
+ @overload
105
+ def qperm(
106
+ *,
107
+ generative: Literal[False],
108
+ synthesize_separately: bool = False,
109
+ unchecked: list[str] | None = None,
110
+ disable_perm_check: bool = False,
111
+ disable_const_checks: list[str] | bool = False,
112
+ ) -> Callable[[Callable], QFunc]: ...
113
+
114
+
115
+ @overload
116
+ def qperm(
117
+ *,
118
+ synthesize_separately: bool,
119
+ unchecked: list[str] | None = None,
120
+ disable_perm_check: bool = False,
121
+ disable_const_checks: list[str] | bool = False,
122
+ ) -> Callable[[Callable], GenerativeQFunc]: ...
123
+
124
+
125
+ @overload
126
+ def qperm(
127
+ *,
128
+ synthesize_separately: bool = False,
129
+ unchecked: list[str] | None = None,
130
+ disable_perm_check: bool = False,
131
+ disable_const_checks: list[str] | bool = False,
132
+ ) -> Callable[[Callable], GenerativeQFunc]: ...
133
+
134
+
135
+ def qperm(
136
+ func: Callable | None = None,
137
+ *,
138
+ external: bool = False,
139
+ generative: bool | None = None,
140
+ synthesize_separately: bool = False,
141
+ unchecked: list[str] | None = None,
142
+ disable_perm_check: bool = False,
143
+ disable_const_checks: list[str] | bool = False,
144
+ ) -> Callable[[Callable], QCallable] | QCallable:
145
+ return _qfunc_inner(
146
+ func=func,
147
+ external=external,
148
+ generative=generative,
149
+ synthesize_separately=synthesize_separately,
150
+ unchecked=unchecked,
151
+ permutation=True,
152
+ disable_perm_check=disable_perm_check,
153
+ disable_const_checks=disable_const_checks,
154
+ )
155
+
156
+
157
+ def _qfunc_inner(
53
158
  *,
159
+ func: Callable | None = None,
54
160
  external: bool = False,
55
- generative: Optional[bool] = None,
161
+ generative: bool | None = None,
56
162
  synthesize_separately: bool = False,
57
- unchecked: Optional[list[str]] = None,
58
- ) -> Union[Callable[[Callable], QCallable], QCallable]:
163
+ unchecked: list[str] | None = None,
164
+ permutation: bool = False,
165
+ disable_perm_check: bool = False,
166
+ disable_const_checks: list[str] | bool = False,
167
+ ) -> Callable[[Callable], QCallable] | QCallable:
59
168
  if generative is None:
60
169
  generative = True
61
170
  if get_global_declarative_switch():
@@ -66,16 +175,30 @@ def qfunc(
66
175
 
67
176
  if external:
68
177
  _validate_directives(synthesize_separately, unchecked)
69
- return ExternalQFunc(func)
178
+ return ExternalQFunc(func, permutation=permutation)
70
179
 
71
180
  if generative:
72
- qfunc = GenerativeQFunc(func)
181
+ qfunc = GenerativeQFunc(func, permutation=permutation)
73
182
  else:
74
- qfunc = QFunc(func)
183
+ qfunc = QFunc(func, permutation=permutation)
75
184
  if synthesize_separately:
76
185
  qfunc.update_compilation_metadata(should_synthesize_separately=True)
77
186
  if unchecked is not None and len(unchecked) > 0:
78
- qfunc.update_compilation_metadata(unchecked=unchecked)
187
+ nonlocal disable_const_checks
188
+ if disable_const_checks:
189
+ raise ClassiqValueError(
190
+ "The 'unchecked' parameter is deprecated, please use 'disable_const_checks' only."
191
+ )
192
+ warnings.warn(
193
+ "The 'unchecked' parameter is deprecated and will no longer be supported starting on 2025-10-30 at the earliest. Please use the 'disable_const_checks' instead.",
194
+ ClassiqDeprecationWarning,
195
+ stacklevel=2,
196
+ )
197
+ disable_const_checks = unchecked
198
+ if disable_perm_check:
199
+ qfunc.update_compilation_metadata(disable_perm_check=disable_perm_check)
200
+ if disable_const_checks:
201
+ qfunc.update_compilation_metadata(disable_const_checks=disable_const_checks)
79
202
  return qfunc
80
203
 
81
204
  if func is not None:
@@ -84,7 +207,7 @@ def qfunc(
84
207
 
85
208
 
86
209
  def _validate_directives(
87
- synthesize_separately: bool, unchecked: Optional[list[str]] = None
210
+ synthesize_separately: bool, unchecked: list[str] | None = None
88
211
  ) -> None:
89
212
  error_msg = ""
90
213
  if synthesize_separately:
@@ -1,6 +1,6 @@
1
1
  import inspect
2
2
  from dataclasses import is_dataclass
3
- from typing import TYPE_CHECKING, Any, Optional, cast, get_origin
3
+ from typing import TYPE_CHECKING, Any, cast, get_origin
4
4
 
5
5
  from classiq.interface.exceptions import ClassiqError, ClassiqValueError
6
6
  from classiq.interface.generator.constant import Constant
@@ -25,7 +25,7 @@ QMODULE_ERROR_MESSAGE = (
25
25
 
26
26
 
27
27
  class QConstant(SymbolicExpr):
28
- CURRENT_QMODULE: Optional[ModelStateContainer] = None
28
+ CURRENT_QMODULE: ModelStateContainer | None = None
29
29
 
30
30
  def __init__(self, name: str, py_type: type, value: Any) -> None:
31
31
  super().__init__(name, False)
@@ -1,4 +1,4 @@
1
- from typing import TYPE_CHECKING, Any, Union
1
+ from typing import TYPE_CHECKING, Any, NoReturn
2
2
 
3
3
  from classiq.interface.exceptions import ClassiqInternalError, ClassiqValueError
4
4
  from classiq.interface.generator.functions.classical_type import (
@@ -41,7 +41,7 @@ class CParamList(CParam):
41
41
  def __init__(
42
42
  self,
43
43
  expr: str,
44
- list_type: Union[ClassicalArray, ClassicalTuple],
44
+ list_type: ClassicalArray | ClassicalTuple,
45
45
  qmodule: ModelStateContainer,
46
46
  ) -> None:
47
47
  super().__init__(expr)
@@ -102,6 +102,9 @@ class CParamList(CParam):
102
102
  return interpret_expression(str(self.len))
103
103
  return CParamScalar(f"{self}.len")
104
104
 
105
+ def __iter__(self) -> NoReturn:
106
+ raise TypeError(f"{type(self).__name__!r} object is not iterable")
107
+
105
108
 
106
109
  class CParamStruct(CParam):
107
110
  def __init__(
@@ -1,5 +1,6 @@
1
1
  import abc
2
2
  import sys
3
+ import warnings
3
4
  from collections.abc import Iterator, Mapping
4
5
  from contextlib import contextmanager
5
6
  from typing import ( # type: ignore[attr-defined]
@@ -10,10 +11,8 @@ from typing import ( # type: ignore[attr-defined]
10
11
  Generic,
11
12
  Literal,
12
13
  NoReturn,
13
- Optional,
14
14
  Protocol,
15
15
  TypeVar,
16
- Union,
17
16
  _GenericAlias,
18
17
  cast,
19
18
  get_args,
@@ -24,6 +23,7 @@ from typing import ( # type: ignore[attr-defined]
24
23
  from typing_extensions import ParamSpec, Self, _AnnotatedAlias
25
24
 
26
25
  from classiq.interface.exceptions import (
26
+ ClassiqDeprecationWarning,
27
27
  ClassiqInternalError,
28
28
  ClassiqNotImplementedError,
29
29
  ClassiqValueError,
@@ -109,9 +109,9 @@ class QVar(Symbolic):
109
109
 
110
110
  def __init__(
111
111
  self,
112
- origin: Union[None, str, HandleBinding] = None,
112
+ origin: None | str | HandleBinding = None,
113
113
  *,
114
- expr_str: Optional[str] = None,
114
+ expr_str: str | None = None,
115
115
  depth: int = 2,
116
116
  ) -> None:
117
117
  name = _infer_variable_name(origin, self.CONSTRUCTOR_DEPTH)
@@ -141,9 +141,9 @@ class QVar(Symbolic):
141
141
  @abc.abstractmethod
142
142
  def to_qvar(
143
143
  cls,
144
- origin: Union[str, HandleBinding],
144
+ origin: str | HandleBinding,
145
145
  type_hint: Any,
146
- expr_str: Optional[str],
146
+ expr_str: str | None,
147
147
  ) -> Self:
148
148
  raise NotImplementedError()
149
149
 
@@ -151,7 +151,7 @@ class QVar(Symbolic):
151
151
  return self._expr_str
152
152
 
153
153
  @property
154
- def size(self) -> Union[CParamScalar, int]:
154
+ def size(self) -> CParamScalar | int:
155
155
  if is_generative_mode():
156
156
  with generative_mode_context(False):
157
157
  return interpret_expression(str(self.size))
@@ -186,9 +186,9 @@ class QScalar(QVar, SymbolicExpr):
186
186
 
187
187
  def __init__(
188
188
  self,
189
- origin: Union[None, str, HandleBinding] = None,
189
+ origin: None | str | HandleBinding = None,
190
190
  *,
191
- _expr_str: Optional[str] = None,
191
+ _expr_str: str | None = None,
192
192
  depth: int = 2,
193
193
  ) -> None:
194
194
  origin = _infer_variable_name(origin, self.CONSTRUCTOR_DEPTH)
@@ -371,9 +371,9 @@ class QBit(QScalar):
371
371
  @classmethod
372
372
  def to_qvar(
373
373
  cls,
374
- origin: Union[str, HandleBinding],
374
+ origin: str | HandleBinding,
375
375
  type_hint: Any,
376
- expr_str: Optional[str],
376
+ expr_str: str | None,
377
377
  ) -> "QBit":
378
378
  return QBit(origin, _expr_str=expr_str)
379
379
 
@@ -428,11 +428,11 @@ class QNum(Generic[_P], QScalar):
428
428
 
429
429
  def __init__(
430
430
  self,
431
- name: Union[None, str, HandleBinding] = None,
432
- size: Union[int, CInt, Expression, SymbolicExpr, None] = None,
433
- is_signed: Union[bool, CBool, Expression, SymbolicExpr, None] = None,
434
- fraction_digits: Union[int, CInt, Expression, SymbolicExpr, None] = None,
435
- _expr_str: Optional[str] = None,
431
+ name: None | str | HandleBinding = None,
432
+ size: int | CInt | Expression | SymbolicExpr | None = None,
433
+ is_signed: bool | CBool | Expression | SymbolicExpr | None = None,
434
+ fraction_digits: int | CInt | Expression | SymbolicExpr | None = None,
435
+ _expr_str: str | None = None,
436
436
  ):
437
437
  if size is None and (is_signed is not None or fraction_digits is not None):
438
438
  raise ClassiqValueError(
@@ -466,9 +466,9 @@ class QNum(Generic[_P], QScalar):
466
466
  @classmethod
467
467
  def to_qvar(
468
468
  cls,
469
- origin: Union[str, HandleBinding],
469
+ origin: str | HandleBinding,
470
470
  type_hint: Any,
471
- expr_str: Optional[str],
471
+ expr_str: str | None,
472
472
  ) -> "QNum":
473
473
  return QNum(origin, *_get_qnum_attributes(type_hint), _expr_str=expr_str)
474
474
 
@@ -480,14 +480,14 @@ class QNum(Generic[_P], QScalar):
480
480
  )
481
481
 
482
482
  @property
483
- def fraction_digits(self) -> Union[CParamScalar, int]:
483
+ def fraction_digits(self) -> CParamScalar | int:
484
484
  if is_generative_mode():
485
485
  with generative_mode_context(False):
486
486
  return interpret_expression(str(self.fraction_digits))
487
487
  return CParamScalar(f"{self}.fraction_digits")
488
488
 
489
489
  @property
490
- def is_signed(self) -> Union[CParamScalar, bool]:
490
+ def is_signed(self) -> CParamScalar | bool:
491
491
  if is_generative_mode():
492
492
  with generative_mode_context(False):
493
493
  return interpret_expression(str(self.is_signed))
@@ -510,12 +510,6 @@ class QNum(Generic[_P], QScalar):
510
510
  fraction_places=self.fraction_digits,
511
511
  )
512
512
 
513
- # Support comma-separated generic args in older Python versions
514
- if sys.version_info[0:2] < (3, 10):
515
-
516
- def __class_getitem__(cls, args) -> _GenericAlias:
517
- return _GenericAlias(cls, args)
518
-
519
513
 
520
514
  class QArray(ArrayBase[_P], QVar, NonSymbolicExpr):
521
515
  CONSTRUCTOR_DEPTH: int = 3
@@ -523,10 +517,10 @@ class QArray(ArrayBase[_P], QVar, NonSymbolicExpr):
523
517
  # TODO [CAD-18620]: improve type hints
524
518
  def __init__(
525
519
  self,
526
- name: Union[None, str, HandleBinding] = None,
527
- element_type: Union[_GenericAlias, QuantumType] = QBit,
528
- length: Optional[Union[int, CInt, SymbolicExpr, Expression]] = None,
529
- _expr_str: Optional[str] = None,
520
+ name: None | str | HandleBinding = None,
521
+ element_type: _GenericAlias | QuantumType = QBit,
522
+ length: int | CInt | SymbolicExpr | Expression | None = None,
523
+ _expr_str: str | None = None,
530
524
  ) -> None:
531
525
  self._element_type = element_type
532
526
  self._length = (
@@ -536,7 +530,7 @@ class QArray(ArrayBase[_P], QVar, NonSymbolicExpr):
536
530
  )
537
531
  super().__init__(name, expr_str=_expr_str)
538
532
 
539
- def __getitem__(self, key: Union[slice, int, SymbolicExpr]) -> Any:
533
+ def __getitem__(self, key: slice | int | SymbolicExpr) -> Any:
540
534
  return (
541
535
  self._get_slice(key) if isinstance(key, slice) else self._get_subscript(key)
542
536
  )
@@ -544,7 +538,7 @@ class QArray(ArrayBase[_P], QVar, NonSymbolicExpr):
544
538
  def __setitem__(self, *args: Any) -> None:
545
539
  pass
546
540
 
547
- def _get_subscript(self, index: Union[slice, int, SymbolicExpr]) -> Any:
541
+ def _get_subscript(self, index: slice | int | SymbolicExpr) -> Any:
548
542
  if isinstance(index, SymbolicExpr) and index.is_quantum:
549
543
  raise ClassiqValueError("Non-classical parameter for slicing")
550
544
 
@@ -589,7 +583,7 @@ class QArray(ArrayBase[_P], QVar, NonSymbolicExpr):
589
583
  else:
590
584
 
591
585
  @property
592
- def len(self) -> Union[CParamScalar, int]:
586
+ def len(self) -> CParamScalar | int:
593
587
  if is_generative_mode():
594
588
  with generative_mode_context(False):
595
589
  return interpret_expression(str(self.len))
@@ -598,9 +592,9 @@ class QArray(ArrayBase[_P], QVar, NonSymbolicExpr):
598
592
  @classmethod
599
593
  def to_qvar(
600
594
  cls,
601
- origin: Union[str, HandleBinding],
595
+ origin: str | HandleBinding,
602
596
  type_hint: Any,
603
- expr_str: Optional[str],
597
+ expr_str: str | None,
604
598
  ) -> "QArray":
605
599
  return QArray(origin, *_get_qarray_attributes(type_hint), _expr_str=expr_str)
606
600
 
@@ -614,6 +608,9 @@ class QArray(ArrayBase[_P], QVar, NonSymbolicExpr):
614
608
  length=self._length,
615
609
  )
616
610
 
611
+ def __iter__(self) -> NoReturn:
612
+ raise TypeError(f"{type(self).__name__!r} object is not iterable")
613
+
617
614
 
618
615
  class QStruct(QVar):
619
616
  CONSTRUCTOR_DEPTH: int = 2
@@ -623,10 +620,10 @@ class QStruct(QVar):
623
620
 
624
621
  def __init__(
625
622
  self,
626
- origin: Union[None, str, HandleBinding] = None,
627
- _struct_name: Optional[str] = None,
628
- _fields: Optional[Mapping[str, QVar]] = None,
629
- _expr_str: Optional[str] = None,
623
+ origin: None | str | HandleBinding = None,
624
+ _struct_name: str | None = None,
625
+ _fields: Mapping[str, QVar] | None = None,
626
+ _expr_str: str | None = None,
630
627
  ) -> None:
631
628
  _register_qstruct(type(self), qmodule=QMODULE)
632
629
  name = _infer_variable_name(origin, self.CONSTRUCTOR_DEPTH)
@@ -654,9 +651,9 @@ class QStruct(QVar):
654
651
  @classmethod
655
652
  def to_qvar(
656
653
  cls,
657
- origin: Union[str, HandleBinding],
654
+ origin: str | HandleBinding,
658
655
  type_hint: Any,
659
- expr_str: Optional[str],
656
+ expr_str: str | None,
660
657
  ) -> "QStruct":
661
658
  field_types = {
662
659
  field_name: (_get_root_type(field_type), field_type)
@@ -699,7 +696,7 @@ def create_qvar_from_quantum_type(quantum_type: ConcreteQuantumType, name: str)
699
696
 
700
697
 
701
698
  def _create_qvar_for_qtype(
702
- qtype: QuantumType, origin: HandleBinding, expr_str: Optional[str] = None
699
+ qtype: QuantumType, origin: HandleBinding, expr_str: str | None = None
703
700
  ) -> QVar:
704
701
  # prevent addition to local handles, since this is used for ports
705
702
  with _no_current_expandable():
@@ -770,6 +767,13 @@ def get_port_from_type_hint(
770
767
  else:
771
768
  quantum_type = _to_quantum_type(py_type)
772
769
 
770
+ if modifier is TypeModifier.Permutable:
771
+ warnings.warn(
772
+ "The `Permutable` type modifier is deprecated and will no longer be supported starting on 2025-10-30 at the earliest. If the function as a whole is a permutation, use `qperm` instead.",
773
+ ClassiqDeprecationWarning,
774
+ stacklevel=1,
775
+ )
776
+
773
777
  return quantum_type, direction, modifier
774
778
 
775
779
 
@@ -868,7 +872,7 @@ def _get_quantum_struct(type_hint: type[QStruct]) -> Struct:
868
872
 
869
873
  def _register_qstruct(
870
874
  type_hint: type[QStruct], *, qmodule: ModelStateContainer
871
- ) -> Optional[QStructDeclaration]:
875
+ ) -> QStructDeclaration | None:
872
876
  struct_name = type_hint.__name__
873
877
  if type_hint is QStruct:
874
878
  return None
@@ -1,13 +1,10 @@
1
1
  import sys
2
2
  from abc import ABC, abstractmethod
3
- from typing import ( # type: ignore[attr-defined]
3
+ from typing import (
4
4
  TYPE_CHECKING,
5
5
  Any,
6
6
  ClassVar,
7
7
  Generic,
8
- Optional,
9
- Union,
10
- _GenericAlias,
11
8
  )
12
9
 
13
10
  from typing_extensions import ParamSpec
@@ -39,13 +36,13 @@ class QExpandableInterface(ABC):
39
36
  self,
40
37
  name: str,
41
38
  qtype: QuantumType,
42
- source_ref: Optional[SourceReference] = None,
39
+ source_ref: SourceReference | None = None,
43
40
  ) -> None:
44
41
  raise NotImplementedError()
45
42
 
46
43
 
47
44
  class QCallable(Generic[P], ABC):
48
- CURRENT_EXPANDABLE: ClassVar[Optional[QExpandableInterface]] = None
45
+ CURRENT_EXPANDABLE: ClassVar[QExpandableInterface | None] = None
49
46
  FRAME_DEPTH = 1
50
47
 
51
48
  @suppress_return_value
@@ -62,12 +59,6 @@ class QCallable(Generic[P], ABC):
62
59
  def func_decl(self) -> AnonQuantumFunctionDeclaration:
63
60
  raise NotImplementedError
64
61
 
65
- # Support comma-separated generic args in older Python versions
66
- if sys.version_info[0:2] < (3, 10):
67
-
68
- def __class_getitem__(cls, args) -> _GenericAlias:
69
- return _GenericAlias(cls, args)
70
-
71
62
  @abstractmethod
72
63
  def create_quantum_function_call(
73
64
  self, source_ref_: SourceReference, *args: Any, **kwargs: Any
@@ -81,5 +72,19 @@ class QCallableList(QCallable, Generic[P], ABC):
81
72
  @property
82
73
  def len(self) -> int: ...
83
74
 
84
- def __getitem__(self, key: Union[slice, int, CInt]) -> "QTerminalCallable":
75
+ def __getitem__(self, key: slice | int | CInt) -> "QTerminalCallable":
76
+ raise NotImplementedError()
77
+
78
+
79
+ class QPerm(QCallable, Generic[P], ABC):
80
+ pass
81
+
82
+
83
+ class QPermList(QCallable, Generic[P], ABC):
84
+ if TYPE_CHECKING:
85
+
86
+ @property
87
+ def len(self) -> int: ...
88
+
89
+ def __getitem__(self, key: slice | int | CInt) -> "QTerminalCallable":
85
90
  raise NotImplementedError()