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/
- Add `libcst/__init__.py` back which I accidentally deleted in another commit. - Add `*.egg-info/` to the gitignore, because `libcst.egg-info` is it's created by pip/setuptools when locally installing libcst, and it's annoying. - Changed the version number from `0.1.dev` to `0.1.dev0`, since pip was warning that it was normalizing the version number from the former to the later. - Add a `python_requires` field, since we know that libcst only works on 3.6+. - Add an `install_requires`. Pip uses this to find dependencies, and ignores `requirements.txt` (since `requirements.txt` is really only intended to be a freeze file). - Add the dataclasses backport as a dependency for Python 3.6. I validated that installing and using libcst works in both 3.6 and 3.7. **Test Plan:** ``` $ python3 -m venv libcst-install-test # my system python is 3.7 $ libcst-install-test/bin/pip install --upgrade pip ipython Cache entry deserialization failed, entry ignored Collecting pip Using cached |
||
|---|---|---|
| libcst | ||
| stubs | ||
| .gitignore | ||
| LICENSE | ||
| README.md | ||
| requirements.txt | ||
| setup.py | ||
LibCST
TODO: Add documentation.
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
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>