Skip to content

Upgrade tree-sitter-language-pack to 1.9.0 (breaks Dart and R parsers) #53

Description

@GoodbyePlanet

Summary

tree-sitter-language-pack is currently held back at >=1.5.0,<1.6.3 (resolved to 1.6.2). The bump to 1.9.0 was excluded from #52 because it breaks the Dart and R parsers. This issue tracks doing the upgrade properly in a dedicated PR.

The problem

In 1.9.0, tree-sitter-language-pack drops its explicit tree-sitter dependency and bundles a newer tree-sitter core. The newer core's parse() no longer accepts a bytes object the way our code calls it, producing:

TypeError: 'bytes' object is not an instance of 'str'
while processing 'source'

This only affects parsers that get their grammar from the language pack — there are no standalone tree-sitter-dart / tree-sitter-r packages in our deps — which is why the other 22 parsers (using their own tree-sitter-<lang> packages) are unaffected.

Affected code

  • server/parser/dart.py:285tree = self._parser.parse(source)
  • server/parser/r.py:126tree = self._parser.parse(source)

Both obtain their parser via from tree_sitter_language_pack import get_parser.

Failing tests

tests/parser/test_dart.py::test_empty_file_returns_no_symbols
tests/parser/test_dart.py::test_canonical_user_widget_fixture
tests/parser/test_r.py::test_empty_file_returns_no_symbols
tests/parser/test_r.py::test_canonical_utils_fixture

(Observed in CI on #52: 4 failed, 200 passed.)

Proposed fix

Adapt the parse() calls in dart.py and r.py to the newer tree-sitter API — likely passing str (or using the encoding= / read-callable form) instead of raw bytes for the language-pack-backed parsers. Verify whether the standalone tree-sitter-<lang> parsers need the same treatment once the bundled core is upgraded, then:

  1. Bump tree-sitter-language-pack to 1.9.0 in pyproject.toml and re-lock.
  2. Update the Dart and R parsers to the new parse() API.
  3. Confirm uv run pytest is fully green.

Context

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions