A collection of AST-based transformations
Project description
AST Transforms
A collection of AST-based Python transformations for manipulating code programmatically.
Installation
pip install ast_transforms
Usage
import ast
import ast_transforms as at
code = '''
@mydecorator
def foo():
print("foo")
'''
# Parse code into an AST
tree = ast.parse(code)
# Apply transformations
tree = at.remove_func_decorator(tree) # removes all function decorators
# Convert AST back to source code
new_code = ast.unparse(tree)
print(new_code)
Output:
def foo():
print("foo")
Passes
remove_func_decorator(tree)– removes all decorators from functions.- More passes are to be added ...
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
ast_transforms-0.2.0.tar.gz
(7.9 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ast_transforms-0.2.0.tar.gz.
File metadata
- Download URL: ast_transforms-0.2.0.tar.gz
- Upload date:
- Size: 7.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9fb3f1147ab319dc30e6991925e91460bcbbefad9f83775851b20ad0291f88a4
|
|
| MD5 |
7d00d4506d4291b5311a854e54e0987b
|
|
| BLAKE2b-256 |
462512d221cc946abab8e185d99ed929ad024a9d4a5d9eda21decf9453a25ec8
|
File details
Details for the file ast_transforms-0.2.0-py3-none-any.whl.
File metadata
- Download URL: ast_transforms-0.2.0-py3-none-any.whl
- Upload date:
- Size: 10.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
81071e93f0675ffce77d2111ce774819b0fbf8c75a95c565881e978b63f413eb
|
|
| MD5 |
9006ecb63a0c523254d4886eb42aa8a0
|
|
| BLAKE2b-256 |
dade3a63d3243a599944e806e27e52b42f4f053c3ea9b503e6bb65777f249161
|