(
while_loop: ast.While,
state: dict[str, Any],
static_tools: dict[str, Callable],
custom_tools: dict[str, Callable],
authorized_imports: list[str],
)
| 438 | |
| 439 | |
| 440 | def evaluate_while( |
| 441 | while_loop: ast.While, |
| 442 | state: dict[str, Any], |
| 443 | static_tools: dict[str, Callable], |
| 444 | custom_tools: dict[str, Callable], |
| 445 | authorized_imports: list[str], |
| 446 | ) -> None: |
| 447 | iterations = 0 |
| 448 | while evaluate_ast(while_loop.test, state, static_tools, custom_tools, authorized_imports): |
| 449 | for node in while_loop.body: |
| 450 | try: |
| 451 | evaluate_ast(node, state, static_tools, custom_tools, authorized_imports) |
| 452 | except BreakException: |
| 453 | return None |
| 454 | except ContinueException: |
| 455 | break |
| 456 | iterations += 1 |
| 457 | if iterations > MAX_WHILE_ITERATIONS: |
| 458 | raise InterpreterError(f"Maximum number of {MAX_WHILE_ITERATIONS} iterations in While loop exceeded") |
| 459 | return None |
| 460 | |
| 461 | |
| 462 | def create_function( |
no test coverage detected
searching dependent graphs…