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
Benjamin Woodruff a45bf3ac2e Improve the reproducibility of setting up a dev environment
- Reorganized the docs a bit to separate "getting started" from
  "development".

- Added a section about setting up a virtualenv (and tested that
  workflow on my machine).

- Added isort, pyre-check, and black to the `requirements.txt`, and
  updated the `requirements.txt` to include exact versions so that we
  can be sure that our tools will behave the same (e.g. there are
  frequently breaking changes between releases of pyre).

- Added a `dev` section to `setup.py`'s `extras_require`. This allows
  you to `pip install -e '.[dev]'` to get a set of development packages
  installed. I used this to help build the updated `requirements.txt`.
  This appears to be a pattern that other projects use.
2019-07-22 19:53:49 -07:00
libcst Improve setup.py compatibility 2019-06-06 15:37:27 -07:00
stubs Initial export of LibCST to github. 2019-05-31 14:16:53 -07:00
.gitignore Improve setup.py compatibility 2019-06-06 15:37:27 -07:00
LICENSE first commit 2019-05-29 11:32:49 -07:00
README.md Improve the reproducibility of setting up a dev environment 2019-07-22 19:53:49 -07:00
requirements.txt Improve the reproducibility of setting up a dev environment 2019-07-22 19:53:49 -07:00
setup.py Improve the reproducibility of setting up a dev environment 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
# 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 -w 88 -m 3 -tc -fgw 0 -lai 2 -ca -ns __init__.py -y && black --target-version py36 libcst/

Running tests

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

find -name "test_*.py" -printf '%P\n' | xargs python3 -m unittest

Verifying types with Pyre

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

pyre --source-directory . --search-path stubs/ check