--- id: tree-sitter version: "0.26.0" license: unclear license_treatment: permissive maintenance: active --- # tree-sitter — Python bindings to the Tree-sitter parsing library License: permissive · Maintenance: active · Popularity: top 1,000 on PyPI ## Install pip install tree-sitter uv add tree-sitter poetry add tree-sitter ## Description # Python Tree-sitter [![CI][ci]](https://github.com/tree-sitter/py-tree-sitter/actions/workflows/ci.yml) [![pypi][pypi]](https://pypi.org/project/tree-sitter/) [![docs][docs]](https://tree-sitter.github.io/py-tree-sitter/) This module provides Python bindings to the [tree-sitter] parsing library. ## Installation The package has no library dependencies and provides pre-compiled wheels for all major platforms. > [!NOTE] > If your platform is not currently supported, please submit an [issue] on GitHub. ```sh pip install tree-sitter ``` ## Usage ### Setup #### Install languages Tree-sitter language implementations also provide pre-compiled binary wheels. Let's take [Python][tree-sitter-python] as an example. ```sh pip install tree-sitter-python ``` Then, you can load it as a `Language` object: ```python import tree_sitter_python as tspython from tree_sitter import Language, Parser PY_LANGUAGE = Language(tspython.language()) ``` ### Basic parsing Create a `Parser` and configure it to use a language: ```python parser = Parser(PY_LANGUAGE) ``` Parse some source code: ```python tree = parser.parse( bytes( """ def foo(): if bar: baz() """,... ## AI interpretation — verify before relying Python bindings to the tree-sitter incremental parsing library, enabling syntax tree construction and traversal for code analysis across multiple programming languages. Verdict: Stable, actively maintained parser binding with zero known vulnerabilities and broad platform coverage. No runtime dependencies and permissive licensing make it suitable for production use. Medium install friction is manageable via pre-built wheels across major platforms. [View on SkillFed](https://skillfed.io/packages/tree-sitter) · [View on PyPI](https://pypi.org/project/tree-sitter/)