tree-sitter-python
Python grammar for tree-sitter
What it is and what it does
tree-sitter-python is a language grammar binding that integrates Python syntax parsing into the tree-sitter incremental parser framework. It allows you to build and query abstract syntax trees for Python code with support for incremental updates—useful when you need to re-parse only the parts of a file that changed rather than the entire file each time.
The package requires Python 3.10 or later and ships as precompiled binaries for common platforms (macOS, Linux, Windows, including ARM variants). It has no runtime dependencies. It's typically used in code analysis tools, linters, IDE plugins, or any system that needs to parse Python source code and work with its syntactic structure.
Use it for:
- Build a code linter or formatter that needs to parse and analyze Python syntax trees incrementally.
- Implement IDE features like syntax highlighting, code completion, or refactoring that benefit from incremental parsing.
- Analyze Python codebases to extract metrics, dependencies, or structural information from the AST.
- Create a code transformation or code generation tool that manipulates Python syntax trees.
- Develop a static analysis tool that traverses Python code structure to detect patterns or violations.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Provides a Python grammar for tree-sitter, enabling incremental parsing and syntax tree analysis of Python code.
Yes, if you need incremental parsing of Python code or are building tools that work with tree-sitter. The package is permissively licensed, has no dependencies, and ships with precompiled binaries for most platforms. However, the last release was 337 days ago—verify that the grammar version meets your Python syntax requirements before committing to it in production.
Install
tree-sitter-python on PyPI
pip
pip install tree-sitter-pythonuv
uv add tree-sitter-pythonpoetry
poetry add tree-sitter-pythonInstalling tree-sitter-python
Before you install
Medium install friction due to precompiled binary wheels across multiple platforms. No runtime dependencies. Last release was 337 days ago; repository is active but aging.
License in practice
MIT license permits unrestricted use, modification, and distribution with minimal attribution requirements.
Quickstart
pip install tree-sitter-python
import tree_sitter_python
# Use with tree-sitter parser to analyze Python code
Requires Python 3.10 or later.
Verify before relying
- Whether the grammar covers all Python 3 syntax features or has known limitations.
- Performance characteristics compared to standard parsing approaches for typical workloads.
- Whether incremental parsing updates are efficient for large files or repeated edits.
Package facts
| License | MIT (permissive) |
| Python support | supports the current Python release (>=3.10) |
| Install friction | medium — platform-specific wheel |
| Runtime dependencies | none |
| Maintenance | aging — 337 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 9,640,716/month — #1,515 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: tree_sitter_python-0.25.0-cp310-abi3-macosx_10_9_x86_64.whl; tree_sitter_python-0.25.0-cp310-abi3-macosx_11_0_arm64.whl; tree_sitter_python-0.25.0-cp310-abi3-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl; tree_sitter_python-0.25.0-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl; tree_sitter_python-0.25.0-cp310-abi3-musllinux_1_2_aarch64.whl; tree_sitter_python-0.25.0-cp310-abi3-musllinux_1_2_x86_64.whl; tree_sitter_python-0.25.0-cp310-abi3-win_amd64.whl; tree_sitter_python-0.25.0-cp310-abi3-win_arm64.whl
Keywords: incremental, parsing, tree-sitter, python
Tags
More Linguistic packages
Detects and normalizes text encoding from…
permissive · top 100 on PyPI
tiktokentiktoken is a fast BPE tokenizer that converts…
permissive · top 1,000 on PyPI
chardetDetects character encoding and language in byte…
permissive · top 1,000 on PyPI
text-unidecodeConverts Unicode text to ASCII by…
copyleft · top 1,000 on PyPI
larkLark is a parsing library that builds abstract…
permissive · top 1,000 on PyPI
tree-sitterPython bindings to the tree-sitter parsing…
permissive · top 1,000 on PyPI
tree-sitter-bashProvides a tree-sitter grammar for parsing Bash…
permissive · top 1,000 on PyPI
tree-sitter-cmakeProvides a tree-sitter grammar for parsing…
permissive · top 15,000 on PyPI
tree-sitter-elixirProvides an Elixir language grammar for…
permissive · top 5,000 on PyPI
tree-sitter-groovyProvides a Groovy language grammar for…
permissive · top 5,000 on PyPI
tree-sitter-haskellProvides a tree-sitter parser grammar for…
permissive · top 15,000 on PyPI
tree-sitter-javaProvides a Java language grammar for…
permissive · top 5,000 on PyPI
tree-sitter-juliaProvides incremental parsing of Julia source…
permissive · top 5,000 on PyPI
tree-sitter-kotlinProvides a Kotlin language grammar for…
permissive · top 5,000 on PyPI
tree-sitter-luaProvides a tree-sitter grammar for parsing Lua…
permissive · top 5,000 on PyPI
tree-sitter-objcProvides a tree-sitter grammar for parsing…
permissive · top 5,000 on PyPI