71 releases (20 breaking)

0.33.1 Jan 13, 2025
0.32.3 Dec 30, 2024
0.30.1 Nov 26, 2024
0.25.4 Jul 26, 2024
0.13.2 Nov 20, 2023

#252 in Programming languages

Download history 188/week @ 2024-10-02 63/week @ 2024-10-09 196/week @ 2024-10-16 18/week @ 2024-10-23 178/week @ 2024-10-30 163/week @ 2024-11-06 30/week @ 2024-11-13 91/week @ 2024-11-20 172/week @ 2024-11-27 146/week @ 2024-12-04 194/week @ 2024-12-11 230/week @ 2024-12-18 109/week @ 2024-12-25 160/week @ 2025-01-01 109/week @ 2025-01-08 30/week @ 2025-01-15

408 downloads per month

MIT license

460KB
14K SLoC

ast-grep python binding

PyPI Website

ast-grep

ast-grep

ast-grep is a tool for code structural search, lint, and rewriting.

This crate intends to build a native python binding of ast-grep and provide a python API for programmatic usage.

Installation

pip install ast-grep-py

Usage

You can take our tests as examples. For example, test_simple.py shows how to use ast-grep to search for a pattern in a file.

Please see the API usage guide and API reference for more details.

Other resources include ast-grep's official site and repository.

Development

Setup virtualenv

python -m venv venv

Activate venv

source venv/bin/activate

Install maturin

pip install maturin[patchelf]

MacOS: Install patchelf and maturin

brew install patchelf
pip install maturin

Build bindings

maturin develop

Run tests

pytest

All tests files are under tests directory.

License

This project is licensed under the MIT license.

Dependencies

~8–19MB
~264K SLoC