Skip to content

fix(gazelle): migrate to official tree-sitter Go bindings - #4272

Merged
aignas merged 4 commits into
bazel-contrib:mainfrom
dougthor42:issue-3416-official-tree-sitter
Oct 16, 2026
Merged

aignas merged 4 commits into
bazel-contrib:mainfrom
dougthor42:issue-3416-official-tree-sitter

Conversation

@dougthor42

@dougthor42 dougthor42 commented Oct 15, 2026 •

Copy link
Copy Markdown
Collaborator

Replace the unmaintained github.com/smacker/go-tree-sitter dependency with the official github.com/tree-sitter/go-tree-sitter and github.com/tree-sitter/tree-sitter-python (v0.25.0) modules. This updates the Python grammar so the Gazelle plugin can parse Python 3.14 PEP 758 unparenthesized multi-exception except clauses without errors.

Because the official bindings include C sources across parent and subdirectory paths that standard go_repository Gazelle generation cannot compile directly, fetch both modules via http_archive with custom cc_library and go_library targets in both Bzlmod and WORKSPACE modes.

We also remove unneeded go_repository items from gazelle/deps.bzl.

Generated by Gemini. Tested on our large-scale QuantumAI monorepo.

TAG=agy

Timing

I ran the parent commit and this PR on our primary QuantumAI monorepo. This PR might make things a little faster, but I didn't want to wait for 5 or more runs in hyperfine 😆.

Parent commit:

$ git -C ../../oss/bazel-contrib/rules_python rev-parse HEAD
b7ec5bd151df5f725ab8f76446fd548ac4fedce1  # agents: require user-visible docs prose and workaround comments (#4271)
$ hyperfine --warmup=1 --runs=3 'bazel run --bes_backend= //:gazelle'
Benchmark 1: bazel run --bes_backend= //:gazelle
  Time (mean ± σ):     93.052 s ± 18.023 s    [User: 99.884 s, System: 6.302 s]
  Range (min … max):   82.134 s … 113.855 s    3 runs

  Warning: Statistical outliers were detected. Consider re-running this benchmark on a quiet system without any interferences from other programs. It might help to use the '--warmup' or '--prepare' options.

This PR:

$ git -C ../../oss/bazel-contrib/rules_python rev-parse HEAD
bc5b12a5e160e7f91f665fc730b9b305dc3471b4
$ hyperfine --warmup=1 --runs=3 'bazel run --bes_backend= //:gazelle'
Benchmark 1: bazel run --bes_backend= //:gazelle
  Time (mean ± σ):     80.338 s ±  2.570 s    [User: 80.271 s, System: 3.808 s]
  Range (min … max):   78.292 s … 83.223 s    3 runs

Fixes #3416

Replace the unmaintained `github.com/smacker/go-tree-sitter` dependency
with the official `github.com/tree-sitter/go-tree-sitter` and
`github.com/tree-sitter/tree-sitter-python` (v0.25.0) modules. This
updates the Python grammar so the Gazelle plugin can parse Python 3.14
PEP 758 unparenthesized multi-exception `except` clauses without errors.

Because the official bindings include C sources across parent and
subdirectory paths that standard `go_repository` Gazelle generation
cannot compile directly, fetch both modules via `http_archive` with
custom `cc_library` and `go_library` targets in both Bzlmod and
WORKSPACE modes.

Generated by Gemini. Tested on our large-scale QuantumAI monorepo.

Fixes 3416. I hope.
Comment thread gazelle/python/file_parser.go
Comment thread gazelle/python/file_parser.go
Comment thread gazelle/deps.bzl Outdated
@aignas
aignas added this pull request to the merge queue Oct 16, 2026
Merged via the queue into bazel-contrib:main with commit 8c780dc Oct 16, 2026
7 checks passed
@dougthor42
dougthor42 deleted the issue-3416-official-tree-sitter branch October 16, 2026 16:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Migrate from smacker/go-tree-sitter to the official tree-sitter/go-tree-sitter

2 participants