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 ...
Metadata
Release files for ast-transforms 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| ast_transforms-0.2.0.tar.gz | 7.9 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| ast_transforms-0.2.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 18.0 kB
Release files / ast_transforms-0.2.0.tar.gz
| Download URL | ast_transforms-0.2.0.tar.gz |
|---|---|
| Size | 7.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9fb3f1147ab319dc30e6991925e91460bcbbefad9f83775851b20ad0291f88a4
|
|
BLAKE2b-256 checksum How to use checksums |
462512d221cc946abab8e185d99ed929ad024a9d4a5d9eda21decf9453a25ec8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.5
|
Release files / ast_transforms-0.2.0-py3-none-any.whl
| Download URL | ast_transforms-0.2.0-py3-none-any.whl |
|---|---|
| Size | 10.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
81071e93f0675ffce77d2111ce774819b0fbf8c75a95c565881e978b63f413eb
|
|
BLAKE2b-256 checksum How to use checksums |
dade3a63d3243a599944e806e27e52b42f4f053c3ea9b503e6bb65777f249161
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.5
|