|
25 | 25 | import inmanta.ast.type as InmantaType |
26 | 26 | import inmanta.execute.dataflow as dataflow |
27 | 27 | from inmanta import plugins |
| 28 | +from inmanta.plugins import CheckedArgs |
28 | 29 | from inmanta.ast import ( |
29 | 30 | ExplicitPluginException, |
30 | 31 | ExternalException, |
@@ -138,7 +139,7 @@ def execute_call( |
138 | 139 | queue: QueueScheduler, |
139 | 140 | result: ResultVariable, |
140 | 141 | *, |
141 | | - checked_args_cache: Optional[list[object]] = None, |
| 142 | + checked_args_cache: Optional[list[Optional[CheckedArgs]]] = None, |
142 | 143 | ) -> None: |
143 | 144 | """ |
144 | 145 | Evaluate this statement, using the output of execute_args |
@@ -195,7 +196,7 @@ def call_in_context( |
195 | 196 | queue: QueueScheduler, |
196 | 197 | result: ResultVariable, |
197 | 198 | *, |
198 | | - checked_args_cache: Optional[list[object]] = None, |
| 199 | + checked_args_cache: Optional[list[Optional[CheckedArgs]]] = None, |
199 | 200 | ) -> None: |
200 | 201 | """ |
201 | 202 | Call this function in the supplied context and store the result in the supplied ResultVariable. |
@@ -227,7 +228,7 @@ def call_in_context( |
227 | 228 | queue: QueueScheduler, |
228 | 229 | result: ResultVariable, |
229 | 230 | *, |
230 | | - checked_args_cache: Optional[list[object]] = None, |
| 231 | + checked_args_cache: Optional[list[Optional[CheckedArgs]]] = None, |
231 | 232 | ) -> None: |
232 | 233 | result.set_value(self.call_direct(args, kwargs), self.ast_node.location) |
233 | 234 |
|
@@ -274,15 +275,16 @@ def call_in_context( |
274 | 275 | queue: QueueScheduler, |
275 | 276 | result: ResultVariable, |
276 | 277 | *, |
277 | | - checked_args_cache: Optional[list[object]] = None, |
| 278 | + checked_args_cache: Optional[list[Optional[CheckedArgs]]] = None, |
278 | 279 | ) -> None: |
279 | 280 |
|
280 | | - if checked_args_cache is not None and checked_args_cache[0] is not None: |
| 281 | + cached = checked_args_cache[0] if checked_args_cache is not None else None |
| 282 | + if cached is not None: |
281 | 283 | # Reuse validated args from a previous call (reschedule after UnsetException). |
282 | 284 | # Type validation and domain conversion are deterministic for the same inputs, |
283 | 285 | # and the DynamicProxy wrappers remain valid since they read from the same |
284 | 286 | # underlying entity instances. |
285 | | - processed_args = checked_args_cache[0] |
| 287 | + processed_args = cached |
286 | 288 | else: |
287 | 289 | processed_args = self.plugin.check_args(args, kwargs) |
288 | 290 | no_unknows = not processed_args.unknowns |
@@ -359,7 +361,7 @@ def __init__( |
359 | 361 | # Cache for validated plugin arguments, reused across reschedules to avoid |
360 | 362 | # redundant type validation when a plugin is retried after UnsetException. |
361 | 363 | # Single-element list used as a mutable slot that can be written to by call_in_context. |
362 | | - self._checked_args_cache: list[object] = [None] |
| 364 | + self._checked_args_cache: list[Optional[CheckedArgs]] = [None] |
363 | 365 |
|
364 | 366 | def execute(self) -> None: |
365 | 367 | # Execution in two stages to prevent re-execution of argument expressions |
|
0 commit comments