--- id: pure-eval version: "0.2.3" license: MIT license_treatment: permissive maintenance: aging --- # pure-eval — Safely evaluate AST nodes without side effects License: permissive · Maintenance: aging · Popularity: top 1,000 on PyPI ## Install pip install pure-eval uv add pure-eval poetry add pure-eval ## Description # `pure_eval` [![Build Status](https://travis-ci.org/alexmojaki/pure_eval.svg?branch=master)](https://travis-ci.org/alexmojaki/pure_eval) [![Coverage Status](https://coveralls.io/repos/github/alexmojaki/pure_eval/badge.svg?branch=master)](https://coveralls.io/github/alexmojaki/pure_eval?branch=master) [![Supports Python versions 3.7+](https://img.shields.io/pypi/pyversions/pure_eval.svg)](https://pypi.python.org/pypi/pure_eval) This is a Python package that lets you safely evaluate certain AST nodes without triggering arbitrary code that may have unwanted side effects. It can be installed from PyPI: pip install pure_eval To demonstrate usage, suppose we have an object defined as follows: ```python class Rectangle: def __init__(self, width, height): self.width = width self.height = height @property def area(self): print("Calculating area...") return self.width * self.height rect = Rectangle(3, 5) ``` Given the `rect` object, we want to evaluate whatever expressions we can in this source code: ```python source = "(rect.width, rect.height, rect.area)" ``` This library works with the AST, so let's parse the source code and... ## AI interpretation — verify before relying Safely evaluates Python AST nodes without triggering side effects, allowing you to extract values from expressions while refusing to execute properties, function calls, or other code with unknown behavior. Verdict: A lightweight, stable utility for safe AST evaluation with no dependencies and permissive licensing. Aging maintenance (last release July 2024) is offset by active repository and zero known vulnerabilities. Well-suited for debuggers, REPLs, and introspection tools that need to inspect code without executing arbitrary logic. [View on SkillFed](https://skillfed.io/packages/pure-eval) · [View on PyPI](https://pypi.org/project/pure-eval/)