28 releases (8 breaking)

new 0.21.1 Apr 24, 2024
0.20.5 Apr 11, 2024
0.20.2 Mar 27, 2024
0.16.0 Dec 29, 2023
0.13.2 Nov 20, 2023

#5 in #codemod

Download history 12/week @ 2024-01-05 15/week @ 2024-01-12 10/week @ 2024-01-26 1/week @ 2024-02-02 100/week @ 2024-02-09 206/week @ 2024-02-16 315/week @ 2024-02-23 30/week @ 2024-03-01 176/week @ 2024-03-08 32/week @ 2024-03-15 401/week @ 2024-03-22 72/week @ 2024-03-29 381/week @ 2024-04-05 68/week @ 2024-04-12 110/week @ 2024-04-19

682 downloads per month

MIT license

365KB
11K 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]

Build bindings

maturin develop

Run tests

pytest

All tests files are under tests directory.

License

This project is licensed under the MIT license.

Dependencies

~7–19MB
~252K SLoC