A concrete syntax tree parser and serializer library for Python that preserves many aspects of Python's abstract syntax tree https://libcst.readthedocs.io/
Find a file
Ray Zeng d3544824fc Wrap _codegen methods in a helper function to track where nodes start and end.
Converts `_codegen` methods into `_codegen_impl` to wrap implementations
to calls to update the position of each node in the `CodegenState`. The
stored position is the syntactic position of a node (that includes any
whitespace attached to that particular node).

Also updates implementation of tool and `CSTNode.__repr__` to not print
fields of `CSTNode` objects prefixed with "_".
2019-07-22 19:53:49 -07:00
libcst Wrap _codegen methods in a helper function to track where nodes start and end. 2019-07-22 19:53:49 -07:00
stubs Initial export of LibCST to github. 2019-05-31 14:16:53 -07:00
.editorconfig Add config files to make tools easier to use 2019-07-22 19:53:49 -07:00
.gitignore Improve setup.py compatibility 2019-06-06 15:37:27 -07:00
.pyre_configuration Add config files to make tools easier to use 2019-07-22 19:53:49 -07:00
LICENSE first commit 2019-05-29 11:32:49 -07:00
pyproject.toml Add config files to make tools easier to use 2019-07-22 19:53:49 -07:00
README.md Add config files to make tools easier to use 2019-07-22 19:53:49 -07:00
requirements-dev.txt Improve the way dependencies are declared 2019-07-22 19:53:49 -07:00
requirements.txt Improve the way dependencies are declared 2019-07-22 19:53:49 -07:00
setup.py Add config files to make tools easier to use 2019-07-22 19:53:49 -07:00

LibCST

TODO: Add documentation.

Getting Started

Examining a sample tree

To examine the tree that is parsed from a particular file, do the following:

python -m libcst.tool print <some_py_file.py>

Development

Start by setting up and activating a virtualenv:

git clone git@github.com:Instagram/LibCST.git libcst
cd libcst
python3 -m venv ../libcst-env/  # just an example, put this wherever you want
source ../libcst-env/bin/activate
pip install --upgrade pip  # optional, if you have an old system version of pip
pip install -r requirements.txt -r requirements-dev.txt
# If you're done with the virtualenv, you can leave it by running:
deactivate

Auto-formatting code with isort and Black

We use isort and black to format code. To format changes to be conformant, run the following in the root:

isort -q -y && black libcst/

Running tests

To run all tests, do the following in the root:

python3 setup.py test

Verifying types with Pyre

To verify types for the library, do the following in the root:

pyre check