fix(extract): warn when files are skipped due to a missing optional dependency (#1745)#1750
Open
rithyKabir wants to merge 1 commit into
Open
Conversation
…ependency (Graphify-Labs#1745) .sql files (and .tf/.hcl/.dm) have a dispatch entry, so the Graphify-Labs#1689 no-extractor warning can't fire; their extractors return an "error" result when the grammar package is absent, so the Graphify-Labs#1666 zero-node warning skips them too. The graph then builds "successfully" while every such file silently contributes nothing. extract() now surfaces these files grouped by extension, naming the optional-dependency extra that restores the language: warning: 2 .sql file(s) contributed nothing to the graph because a dependency is missing: tree_sitter_sql not installed. Install it with: pip install "graphifyy[sql]" (Graphify-Labs#1745) Regression tests cover the warning (via a simulated missing tree_sitter_sql) and the no-warning case when the extra is installed. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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.
Fixes #1745.
Problem
When the
[sql]extra isn't installed,extract_sqlreturns an"error"result for every.sqlfile — and nothing consumes it. Both existing safety nets deliberately miss this case:error.sqlhas oneSo the graph builds "successfully" while the entire SQL schema silently contributes nothing. The same mechanism affects the other optional grammars that hard-fail on import:
.tf/.tfvars/.hcl([terraform]) and.dm/.dme([dm]). Pascal is unaffected — it falls back to its regex extractor.Fix
extract()now surfaces these files right after the #1689 block, grouped by extension, naming the extra that restores the language:A new
_EXTRA_FOR_EXTENSIONmap lives next to_DISPATCHso the two stay in sight of each other. For a missing core grammar (broken env), the extension isn't in the map and the extractor's own error is printed verbatim with no extra hint.Tests
Mirrors the #1689 regression tests: one simulates the missing dependency (
monkeypatch.setitem(sys.modules, "tree_sitter_sql", None)) and asserts the warning fires while a sibling.pyfile still extracts normally; one asserts no warning when the extra is installed. Fulltests/test_extract.pypasses (117/117), ruff clean.🤖 Generated with Claude Code