(
expression: ast.UnaryOp,
state: dict[str, Any],
static_tools: dict[str, Callable],
custom_tools: dict[str, Callable],
authorized_imports: list[str],
)
| 394 | |
| 395 | |
| 396 | def evaluate_unaryop( |
| 397 | expression: ast.UnaryOp, |
| 398 | state: dict[str, Any], |
| 399 | static_tools: dict[str, Callable], |
| 400 | custom_tools: dict[str, Callable], |
| 401 | authorized_imports: list[str], |
| 402 | ) -> Any: |
| 403 | operand = evaluate_ast(expression.operand, state, static_tools, custom_tools, authorized_imports) |
| 404 | if isinstance(expression.op, ast.USub): |
| 405 | return -operand |
| 406 | elif isinstance(expression.op, ast.UAdd): |
| 407 | return operand |
| 408 | elif isinstance(expression.op, ast.Not): |
| 409 | return not operand |
| 410 | elif isinstance(expression.op, ast.Invert): |
| 411 | return ~operand |
| 412 | else: |
| 413 | raise InterpreterError(f"Unary operation {expression.op.__class__.__name__} is not supported.") |
| 414 | |
| 415 | |
| 416 | def evaluate_lambda( |
no test coverage detected
searching dependent graphs…