--- id: asttokens version: "3.0.2" license: Apache 2.0 license_treatment: permissive maintenance: active --- # asttokens — Annotate AST trees with source code positions License: permissive · Maintenance: active · Popularity: top 1,000 on PyPI ## Install pip install asttokens uv add asttokens poetry add asttokens ## Description ASTTokens ========= .. image:: https://img.shields.io/pypi/v/asttokens.svg :target: https://pypi.python.org/pypi/asttokens/ .. image:: https://img.shields.io/pypi/pyversions/asttokens.svg :target: https://pypi.python.org/pypi/asttokens/ .. image:: https://github.com/gristlabs/asttokens/actions/workflows/build-and-test.yml/badge.svg :target: https://github.com/gristlabs/asttokens/actions/workflows/build-and-test.yml .. image:: https://readthedocs.org/projects/asttokens/badge/?version=latest :target: https://asttokens.readthedocs.io/en/latest/index.html .. image:: https://coveralls.io/repos/github/gristlabs/asttokens/badge.svg :target: https://coveralls.io/github/gristlabs/asttokens .. Start of user-guide The ``asttokens`` module annotates Python abstract syntax trees (ASTs) with the positions of tokens and text in the source code that generated them. It makes it possible for tools that work with logical AST nodes to find the particular text that resulted in those nodes, for example for automated refactoring or highlighting. Installation ------------ asttokens is available on PyPI: https://pypi.python.org/pypi/asttokens/:: pip install asttokens The... ## AI interpretation — verify before relying Annotates Python abstract syntax trees with the precise source code positions and text of tokens, enabling tools to map logical AST nodes back to their originating code for refactoring, analysis, and transformation. Verdict: A stable, actively maintained library with zero known vulnerabilities, no external dependencies, and broad Python version support (3.8–3.14). Well-suited for code analysis and refactoring tools that need to bridge AST nodes and source text. [View on SkillFed](https://skillfed.io/packages/asttokens) · [View on PyPI](https://pypi.org/project/asttokens/)