MCPcopy
hub / github.com/huggingface/smolagents / evaluate_unaryop

Function evaluate_unaryop

src/smolagents/local_python_executor.py:396–413  ·  view source on GitHub ↗
(
    expression: ast.UnaryOp,
    state: dict[str, Any],
    static_tools: dict[str, Callable],
    custom_tools: dict[str, Callable],
    authorized_imports: list[str],
)

Source from the content-addressed store, hash-verified

394
395
396def 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
416def evaluate_lambda(

Callers 1

evaluate_astFunction · 0.85

Calls 2

evaluate_astFunction · 0.85
InterpreterErrorClass · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…