Repository navigation
deps: move tree-sitter-language-pack to 1.x, with a clear error when a grammar cannot be downloaded - #156
Open
fabceolin wants to merge 2 commits into
Open
deps: move tree-sitter-language-pack to 1.x, with a clear error when a grammar cannot be downloaded#156fabceolin wants to merge 2 commits into
fabceolin wants to merge 2 commits into
Conversation
…ents from the call The pin goes from >=0.8.0,<0.9.0 to >=1.23.1,<2.0.0. Grammars that 0.8 does not ship (Lean, among others) are only in 1.x. The 1.x Dart grammar parses `Foo<T>(x)` as an identifier with a call selector whose argument_part holds the type_arguments, not as a relational expression. `_handle_generic_invocation` never saw it, so the type-argument edges (`Garage.open -> Item`, `carProvider -> Car`) were lost. `_process_chain` now takes them from the call. The relational expression path stays for grammars that still misparse it. 1.x downloads each grammar on first use and caches it. The Docker image fetches the grammars the analyzers load at build time, so it runs offline. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… cannot be downloaded tree-sitter-language-pack 1.x downloads each grammar on first use. Without network access the first load raises a DownloadError that names a URL but not the cause or the fix, and the per-file except blocks of the analyzers swallow it, so the language drops out of the graph with a traceback per file. `utils/grammars.py` loads pack grammars through `get_pack_parser`, which turns the DownloadError into a GrammarUnavailableError that names the grammar, the cache folder and the `t.download([...])` command. `analyze_code_files` calls `ensure_pack_grammars` before the first file, so the run stops once. `PACK_GRAMMARS_BY_LANGUAGE` lists the grammars each language loads, and a test checks that docker/Dockerfile downloads the same set. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Moves
tree-sitter-language-packfrom>=0.8.0,<0.9.0to>=1.23.1,<2.0.0,as agreed in #154. This is the first of two stacked PRs. The Lean 4 analyzer
follows on top of this branch.
Changes
pyproject.tomlhas>=1.23.1,<2.0.0, andrequirements.txthas==1.23.1.tree-sitter==0.26.0does not change. Pack 1.x declarestree-sitter>=0.23.Foo<T>(x)as a call whoseargument_partholdstype_arguments, not as arelational_expression._process_chainnow reads the type arguments from the call. Without thischange,
test_call_resolution_rulesandtest_riverpod_and_router_edgesfail, because the
Garage.open -> ItemandcarProvider -> Caredges arelost.
docker/Dockerfiledownloads the grammars theanalyzers load (
dart,go,javascript,typescript,vue,zig), sothe image runs offline.
use. Without network access, the first load raised a
DownloadErrorthatnames a URL only. The per-file
exceptblocks also caught it, so thelanguage dropped out of the graph with a traceback for each file.
utils/grammars.pyloads pack grammars throughget_pack_parser. Itchanges the
DownloadErrorinto aGrammarUnavailableErrorthat names thegrammar, the cache folder and the
t.download([...])command.analyze_code_filescallsensure_pack_grammarsbefore the first file,so the run stops one time. The CLI shows the message through its usual
Analysis failed: ...path.PACK_GRAMMARS_BY_LANGUAGElists the grammars that each language loads.A test checks that
docker/Dockerfiledownloads the same set.guides/development.mdnow usesget_pack_parser.Example message, with an empty cache and no network:
Tests
tests/test_pack_grammars.py(new, 5 tests) covers the error message, thatonly the grammars of the present languages load, that the analysis stops
before the first file, and that the Dockerfile list matches.
test_doc_write_guard.py::test_warning_reports_rejected_tool_callsalsofails on
main(a1b9f4a) in a fresh install, so it is not related to thischange.
ruff checkandruff format --checkpass.docker build -f docker/Dockerfile .passes. In the image,get_parserloads all six grammars with
--network none.Out of scope: the image still needs network access at import time, because
codewiki/src/be/utils.pyloads the tiktokencl100k_baseencoding when themodule is imported. This is already so on
main. I can open a separate issue.Note:
tests/test_pack_grammars.pyis added withgit add -f, because.gitignorehastests/*, like the other test files.Refs #154
🤖 Generated with Claude Code