mirror of
https://github.com/Instagram/LibCST.git
synced 2025-12-23 10:35:53 +00:00
A concrete syntax tree parser and serializer library for Python that preserves many aspects of Python's abstract syntax tree
https://libcst.readthedocs.io/
Currently, a lot of libcst node tests use data providers that use tuples instead of dictionaries. This just makes the tests unreadable, so this is one of several diffs aiming to solve this issue. |
||
|---|---|---|
| .circleci | ||
| .github | ||
| libcst | ||
| stubs | ||
| .editorconfig | ||
| .flake8 | ||
| .gitignore | ||
| .pyre_configuration | ||
| CODE_OF_CONDUCT.md | ||
| CONTRIBUTING.md | ||
| LICENSE | ||
| pyproject.toml | ||
| README.md | ||
| requirements-dev.txt | ||
| requirements.txt | ||
| setup.py | ||
| tox.ini | ||
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.