Repository navigation
fix(parsers): recover Python annotated parameters (40% loss) and Go grouped imports - #1561
Merged
Merged
Conversation
Two parser defects that silently dropped large fractions of the graph. Python — annotated parameters without a default (#1520) `typed_parameter` has no `name` field in tree-sitter-python, only `type`. Looking one up returned None, so every `x: int` parameter was discarded. `x: int = 5` survived only because it is a different node type (`typed_default_parameter`, which does have the field), which is why the gap went unnoticed. Read the first child instead, covering the `*args: T` and `**kw: T` splat forms too. Measured against the stdlib `ast` module over `src/codegraphcontext/`: before: 1952 / 3271 parameters extracted (1319 lost, 40.3%) after: 3271 / 3271 (0 lost) Go — grouped `import (...)` blocks (#1521) The imports query required `import_spec` to be a direct child of `import_declaration`. That shape only occurs for a single-line `import "fmt"`; a grouped block nests the specs inside an `import_spec_list`. Since gofmt groups any file with more than one import, essentially every real Go file lost every import — and with no Module nodes there is nothing for cross-file resolution to work from. Added the nested alternatives for both the plain and aliased forms. Goldens for `sample_project` (+4 Parameter) and `sample_project_go` (+14 Module) regenerated; both diffs are purely additive, no nodes lost. Co-Authored-By: Claude Fable 5 <[email protected]>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
|
Hi! 👋 Join our CodeGraphContext Discord channel to collaborate: https://discord.gg/dR4QY32uYQ |
Contributor
🔍 PR Code Graph Analysisfix(parsers): recover Python annotated parameters (40% loss) and Go grouped imports (#1561) 📊 Interactive VisualizationView the blast radius graph: PR Reviewer Dashboard 📦 ArtifactsThe graph JSON has been uploaded as a build artifact: Generated by CodeGraphContext using FalkorDB Lite |
This was referenced Aug 2, 2026
Shashankss1205
added a commit
that referenced
this pull request
Aug 2, 2026
Bug-fix release. Since 0.5.4 on PyPI: - fix(indexer): record non-code files on the SCIP path so `cgc index` stops reporting a partial index forever (#1565, #1566) - fix(parsers): capture PHP imports rather than trait uses (#1522, #1563) - fix(parsers): recover Python annotated parameters — 40.3% of parameters were being dropped — and Go grouped imports (#1520, #1521, #1561) - fix(graph): always sanitize bundle filenames (#1517, #1541) - fix(cli/mcp): read import aliases from the IMPORTS relationship (#1515, #1540) - fix(cli/mcp): fall back to JSON when GCF encoding fails (#1518, #1539) Co-authored-by: Claude Fable 5 <[email protected]>
This branch was successfully 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.
Fixes #1520 and #1521 — two parser defects that silently dropped large fractions of the graph. Both were found by an audit and are reproduced below.
Full suite: 1065 passed, 7 skipped, no failures.
Python — annotated parameters without a default (#1520)
typed_parameterhas nonamefield in tree-sitter-python; it exposes onlytype. Its children are(<identifier|splat>, ':', type):So
child_by_field_name('name')returnedNoneand the parameter was discarded.x: int = 5survived only because it is a different node type —typed_default_parameter, which does have the field — which is exactly why this went unnoticed for so long.The fix reads the first child instead, and covers the splat forms (
*args: int,**kw: str) that also appear in that position.Measured against the stdlib
astmodule oversrc/codegraphcontext/:ast)Since this repo is heavily annotated, self-indexing was losing over 40% of
Parameternodes and theirHAS_PARAMETERedges.Go — grouped
import (...)blocks (#1521)The imports query required
import_specto be a direct child ofimport_declaration. That shape only occurs for a single-lineimport "fmt"; a grouped block nests them one level deeper:gofmt rewrites any file with more than one import into a grouped block, so essentially every real Go file lost every import. With no
Modulenodes and noIMPORTSedges, cross-file call resolution for Go had nothing to work from.Added the nested alternatives for both the plain and aliased forms. Verified:
The repo's own
sample_project_go/main.gofixture went from 0 imports to 2.Goldens
sample_projectandsample_project_goregenerated. Both diffs are purely additive — verified by counting node labels before and after:No nodes lost in either. I deliberately did not touch the goldens for other languages.
Note for reviewers
Fixing parsers changes what the graph contains, so node and edge counts will move. That is the point of the change, but it will shift the numbers in #1393 and is worth keeping in mind for the Database Parity Check. The remaining parser bugs (#1522 PHP, #1523 Ruby, #1524 C/C++, #1526 JS/TS) will each do the same, so they are probably best merged deliberately rather than all at once.
🤖 Generated with Claude Code