ASTFormatter
The ASTFormatter class accepts an AST tree and returns a valid source code representation of that tree.
Example Usage
from astformatter import ASTFormatter
import ast
tree = ast.parse(open('modulefile.py'), 'modulefile.py', mode='exec')
src = ASTFormatter().format(tree, mode='exec')
Bugs
Currently, indentation is fixed at 4 spaces.
Too many methods are exposed that shouldn’t be, in order to properly subclass ast.NodeVisitor.
Need to make the statement visitor methods consistent about returning a list of strings; most still just return a string.
Code modified to work with 3.x needs cleanup
Latest Changes
0.6.4 (2017-06-25)
Process docstring if exsts in Module, ClassDef, and FunctionDef nodes. #9 (darkfoxprime)
Add parens around unary operands if necessary #8 (zerebubuth)
Copyright
Copyright © 2015-2016 by Johnson Earls. Some rights reserved. See the license for details.
Metadata
Release files for ASTFormatter 0.6.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| ASTFormatter-0.6.4.tar.gz | 7.6 kB | Without provenance | Details for ASTFormatter-0.6.4.tar.gz |
Release files / ASTFormatter-0.6.4.tar.gz
| Download URL | ASTFormatter-0.6.4.tar.gz |
|---|---|
| Size | 7.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e24e7763bcc8c96d4c7f86b6be2ab524911fc69af9e1d1580113759c5ab12002
|
|
BLAKE2b-256 checksum How to use checksums |
1fcd4693e78b97d1bb7525a460be2907922f4432e752a6057b2b942bb38345e7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for ASTFormatter 0.6.4
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.