Skip to content

extract_symbols() broken with tree-sitter-language-pack>=1.0 #197

Description

@chang-andrew

Summary

Fresh install of cased-kit==3.5.1 declares tree-sitter-language-pack>=0.7.2 with no upper bound. As of tree-sitter-language-pack==1.0.0, get_parser() was changed to return a bundled native (Rust) parser instead of a tree_sitter.Parser. Its node objects are incompatible with the tree_sitter.QueryCursor API that TreeSitterSymbolExtractor.extract_symbols() uses, so symbol extraction fails on a fresh install (which resolves to the latest, 1.10.x).

Environment

  • cased-kit==3.5.1
  • tree-sitter-language-pack==1.10.1
  • tree-sitter==0.25.2
  • Python 3.14, macOS

Reproduction

from kit import Repository
repo = Repository("./")
repo.extract_symbols()

(same results using CLI)

Observed

First, every file errors out of extract_symbols():

[EXTRACT] Error parsing or processing file with ext .js: 'bytes' object is not an instance of 'str'

Traceback (most recent call last):
  File ".../kit/tree_sitter_symbol_extractor.py", line 371, in extract_symbols
    tree = parser.parse(bytes(source_code, "utf8"))
TypeError: 'bytes' object is not an instance of 'str'

The 1.x native parser expects str, not bytes. I tried changing that line to pass str, but extraction then fails at the query stage:

[EXTRACT] No compatible tree-sitter API found for extension .js

…and extract_symbols() silently returns []. The 1.x parser's Tree/Node come from the bundled native module (builtins-level types, root_node is a method), whereas get_language()/get_query() and tree_sitter.QueryCursor come from the tree-sitter PyPI package. The two ABIs don't interoperate, so QueryCursor.matches(root) raises TypeError: ... must be tree_sitter.Node.

Workaround

Pin below the breaking change:

"tree-sitter-language-pack<1.0" # resolves to 0.13.0

With 0.13.0, extract_symbols() works unmodified (verified: 2089 symbols extracted from my project).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions