Skip to content

Latest commit

 

History

History
84 lines (55 loc) · 4.13 KB

README.md

File metadata and controls

84 lines (55 loc) · 4.13 KB

awesome-python-ast

Python tools, libraries and resources about AST (as in Abstract Syntax Trees)

Online resources

Tools

  • astmonkey - Set of tools to play with Python AST
  • astor - AST read/write
  • astpath - A command-line search utility for Python ASTs using XPath syntax.
  • astpretty - Pretty print the output of python stdlib ast.parse.
  • astroid - A common base representation of python source code for pylint and other projects
  • astsearch - Search through ASTs using XPath syntax
  • astunparse - a factored out version of unparse found in the Python source distribution
  • baron - a Full Syntax Tree (FST) library
  • parso - parser that supports error recovery and round-trip parsing
  • redbaron - Bottom-up approach to refactoring in python
  • show_ast - An IPython notebook plugin for visualizing ASTs.
  • tokenize-rt - A wrapper around the stdlib tokenize which roundtrips.

Unused code detection

Formatters

  • autopep8 - A tool that automatically formats Python code to conform to the PEP 8 style guide
  • black - The uncompromising Python code formatter | Online demo
  • yapf - configurable formatter from Google | Online demo

Linters

  • flake8 - glues together pycodestyle, pyflakes, mccabe, and third-party plugins to check the style and quality of code
  • mccabe - McCabe complexity checker
  • pycodestyle - former pep8. Check your Python code against some of the style conventions in PEP 8.
  • pydocstyle - docstring style checker
  • pyflakes - A simple program which checks Python source files for errors.
  • pylint - code analysis tool which looks for programming errors, helps enforcing a coding standard, sniffs for code smells and offers simple refactoring suggestions.

Import sorters

Other

  • add-trailing-comma - A tool (and pre-commit hook) to automatically add trailing commas to calls and literals.
  • pyupgrade - A tool (and pre-commit hook) to automatically upgrade syntax for newer versions of the language.
  • yesqa - A tool (and pre-commit hook) to automatically remove unnecessary # noqa comments

Online tools

Articles

2010-02-22: Instrumenting the AST

Code examples

TODOs

  • common dependencies
  • "getting into" howto
  • static/dynamic code analysis
  • pluggable or not