Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/smolagents/local_python_executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -1608,6 +1608,10 @@ def evaluate_python_code(
A dictionary mapping variable names to values. The `state` should contain the initial inputs but will be
updated by this function to contain all variables as they are evaluated.
The print outputs will be stored in the state under the key "_print_outputs".
authorized_imports (`list[str]`, *optional*, defaults to `BASE_BUILTIN_MODULES`):
List of module names that the evaluated code is allowed to import.
max_print_outputs_length (`int`, *optional*, defaults to `DEFAULT_MAX_LEN_OUTPUT`):
Maximum length of captured print outputs before they get truncated.
timeout_seconds (`int`, *optional*, defaults to `MAX_EXECUTION_TIME_SECONDS`):
Maximum time in seconds allowed for code execution. Set to `None` to disable timeout.
"""
Expand Down
10 changes: 10 additions & 0 deletions tests/test_local_python_executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -2987,3 +2987,13 @@ def test_vulnerability_via_dunder_call(
)
with expectation:
executor(code)


def test_evaluate_python_code_docstring_parameters():
import inspect

sig = inspect.signature(evaluate_python_code)
doc = evaluate_python_code.__doc__
assert doc is not None
for param_name in sig.parameters:
assert param_name in doc, f"Parameter '{param_name}' is not documented in evaluate_python_code docstring."