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
Jennifer Taylor 3b3f52673a Rework 'pass' on removal behavior
Instead of generating Pass nodes on removal, allow empty IndentedBlock,
SimpleStatementLine and SimpleStatementSuite nodes. Have them insert a
'pass' token manually when they encounter having nothing inside of
them. This allows us to more easily figure out when we should keep a
node around, and means that we no longer construct new nodes with
surprising subnodes based on somewhat-related user input. It also
matches how we do MaybeSentinel support for the rest of Python's
syntactic sugar. As a bonus (well, the point of this diff actually), we
no longer add a pass statement every time we remove another statement,
only when we actually need to.
2019-07-22 20:04:37 -07:00
.circleci add pyre CI job 2019-07-22 20:04:29 -07:00
.github add initial PULL_REQUEST_TEMPLATE.md 2019-07-22 19:59:57 -07:00
libcst Rework 'pass' on removal behavior 2019-07-22 20:04:37 -07:00
stubs Add runtime type validation support 2019-07-22 19:53:49 -07:00
.editorconfig Add config files to make tools easier to use 2019-07-22 19:53:49 -07:00
.flake8 add flake8 and config 2019-07-22 19:59:57 -07:00
.gitignore add .tox/ to gitignore 2019-07-22 19:53:49 -07:00
.pyre_configuration add pyre CI job 2019-07-22 20:04:29 -07:00
CODE_OF_CONDUCT.md add Code Of Conduct file 2019-07-22 19:59:50 -07:00
CONTRIBUTING.md add test command and rephrase coding style. 2019-07-22 19:59:57 -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 license section in README 2019-07-22 19:53:49 -07:00
requirements-dev.txt add missing flake8 dependency in requirements-dev.txt to fix lint CI job 2019-07-22 20:04:37 -07:00
requirements.txt Add runtime type validation support 2019-07-22 19:53:49 -07:00
setup.py add missing flake8 dependency in requirements-dev.txt to fix lint CI job 2019-07-22 20:04:37 -07:00
tox.ini add pyre CI job 2019-07-22 20:04:29 -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

License

LibCST is MIT licensed, as found in the LICENSE file.