skillfed

tree-sitter-python

Python grammar for tree-sitter

tree-sitter-python v0.25.0 9.6M downloads/30d#1,515 on PyPI561
Permissive license MIT AGING released

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-python

uv

uv add tree-sitter-python

poetry

poetry add tree-sitter-python

Installing 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

Intended Audience :: DevelopersTopic :: Software Development :: CompilersTopic :: Text Processing :: LinguisticTyping :: Typed

Tags

python parser tree-sitterincremental parsing pythonsyntax tree analysispython grammar parsercode parsing tree-sitterast generation pythonpython language grammar
parsingsyntax-analysisincremental-parsing

More Linguistic packages