interpretthis 0.2.0

Sandboxed Python AST interpreter for untrusted and LLM-generated code
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
// Copyright 2026 Thomas Santerre and Moderately AI Inc.
//
// SPDX-License-Identifier: MIT OR Apache-2.0

use rustpython_parser::{
    Parse,
    ast::{self, Suite},
};

use crate::error::InterpreterError;

/// Parse Python source code into an AST suite (list of statements).
pub fn parse(code: &str) -> Result<Suite, InterpreterError> {
    ast::Suite::parse(code, "<interpreter>").map_err(|e| InterpreterError::Syntax(format!("{e}")))
}