└── README.md /README.md: -------------------------------------------------------------------------------- 1 | # awesome-python-ast 2 | Python tools, libraries and resources about AST (as in Abstract Syntax Trees) 3 | 4 | 5 | ## Online resources 6 | 7 | - [brown-water-python](https://www.asmeurer.com/brown-water-python/) 8 | 9 | _"extended documentation for effectively working with the tokenize module"_ 10 | 11 | Project of [Aaron Meurer](https://twitter.com/asmeurer) | 12 | [Repo](https://github.com/asmeurer/brown-water-python) 13 | 14 | - [greentreesnakes](https://greentreesnakes.readthedocs.io/) 15 | 16 | _"the missing Python AST docs"_ 17 | 18 | Project of [Thomas Kluyver](https://twitter.com/takluyver) | 19 | [Repo](https://bitbucket.org/takluyver/greentreesnakes). 20 | 21 | 22 | ## Tools 23 | 24 | - [astmonkey](https://github.com/mutpy/astmonkey) - Set of tools to play with Python AST 25 | - [astor](https://github.com/berkerpeksag/astor) - AST read/write 26 | - [astpath](https://github.com/hchasestevens/astpath) - A command-line search utility for Python ASTs using XPath syntax. 27 | - [astpretty](https://github.com/asottile/astpretty) - Pretty print the output of python stdlib `ast.parse`. 28 | - [astroid](https://github.com/PyCQA/astroid) - A common base representation of python source code for pylint and other projects 29 | - [astsearch](https://github.com/takluyver/astsearch) - Search through ASTs using XPath syntax 30 | - [astunparse](https://github.com/simonpercivall/astunparse) - a factored out version of unparse found in the Python source distribution 31 | - [baron](https://github.com/PyCQA/baron) - a Full Syntax Tree (FST) library 32 | - [parso](https://github.com/davidhalter/parso) - parser that supports error recovery and round-trip parsing 33 | - [redbaron](https://github.com/PyCQA/redbaron) - Bottom-up approach to refactoring in python 34 | - [show_ast](https://github.com/hchasestevens/show_ast) - An IPython notebook plugin for visualizing ASTs. 35 | - [tokenize-rt](https://github.com/asottile/tokenize-rt) - A wrapper around the stdlib `tokenize` which roundtrips. 36 | 37 | 38 | ## Unused code detection 39 | - [dead](https://github.com/asottile/dead) 40 | - [vulture](https://github.com/jendrikseipp/vulture) 41 | 42 | 43 | ## Formatters 44 | - [autopep8](https://github.com/hhatto/autopep8) - A tool that automatically formats Python code to conform to the PEP 8 style guide 45 | - [black](https://github.com/python/black) - The uncompromising Python code formatter | [Online demo](https://black.now.sh) 46 | - [yapf](https://github.com/google/yapf) - configurable formatter from Google | [Online demo](https://yapf.now.sh/) 47 | 48 | 49 | ## Linters 50 | - [flake8](https://gitlab.com/pycqa/flake8) - glues together pycodestyle, pyflakes, mccabe, and third-party plugins to check the style and quality of code 51 | - [mccabe](https://github.com/PyCQA/mccabe) - McCabe complexity checker 52 | - [pycodestyle](https://github.com/PyCQA/pycodestyle) - former `pep8`. Check your Python code against some of the style conventions in PEP 8. 53 | - [pydocstyle](https://github.com/PyCQA/pydocstyle) - docstring style checker 54 | - [pyflakes](https://github.com/PyCQA/pyflakes) - A simple program which checks Python source files for errors. 55 | - [pylint](https://github.com/PyCQA/pylint) - code analysis tool which looks for programming errors, helps enforcing a coding standard, sniffs for code smells and offers simple refactoring suggestions. 56 | 57 | ## Import sorters 58 | - [isort](https://github.com/timothycrosley/isort) - sort imports alphabetically, and automatically separated into sections 59 | - [reorder_python_imports](https://github.com/asottile/reorder_python_imports) - reordering python imports 60 | 61 | 62 | ## Other 63 | - [add-trailing-comma](https://github.com/asottile/add-trailing-comma) - A tool (and pre-commit hook) to automatically add trailing commas to calls and literals. 64 | - [pyupgrade](https://github.com/asottile/pyupgrade) - A tool (and pre-commit hook) to automatically upgrade syntax for newer versions of the language. 65 | - [yesqa](https://github.com/asottile/yesqa) - A tool (and pre-commit hook) to automatically remove unnecessary # noqa comments 66 | 67 | 68 | ## Online tools 69 | - [python-ast-explorer](https://github.com/maligree/python-ast-explorer) 70 | 71 | 72 | 73 | ## Articles 74 | 2010-02-22: [Instrumenting the AST](http://www.dalkescientific.com/writings/diary/archive/2010/02/22/instrumenting_the_ast.html) 75 | 76 | 77 | ## Code examples 78 | 79 | 80 | ## TODOs 81 | - common dependencies 82 | - "getting into" howto 83 | - static/dynamic code analysis 84 | - pluggable or not 85 | --------------------------------------------------------------------------------