Skip to content

fix(tests): python's tree-sitter args-counter only measured bare identifiers - #1525

Merged
squid-protocol merged 1 commit into
mainfrom
fix/python-tree-sitter-args-node-types
Aug 14, 2026
Merged

fix(tests): python's tree-sitter args-counter only measured bare identifiers#1525
squid-protocol merged 1 commit into
mainfrom
fix/python-tree-sitter-args-node-types

Conversation

@squid-protocol

Copy link
Copy Markdown
Owner

Summary

  • _get_param_count() in tests/tools/tree_sitter_accuracy_audit.py resolves python's
    function_definition parameter list directly via the generic parameters-field branch, but
    that branch's counted_types whitelist only had JS/C-family node type names — none of
    tree-sitter-python's own per-parameter wrapper types (typed_parameter, default_parameter,
    typed_default_parameter, list_splat_pattern, dictionary_splat_pattern). Only a fully bare
    x (no type, no default) was ever counted.
  • Same false-defect shape as rust func_start misses bodyless multi-line trait method signatures (deserialize_* family) #1319/tree_sitter_accuracy_audit: _get_param_count node-type whitelist missing real per-language parameter node types (11 languages) #1339, just never caught for python since it routes through the
    generic top-level branch instead of one of the special-cased fallback branches those issues
    audited.
  • This is a bug in the audit tool, not GitGalaxy's own args regex (detector.py's
    _count_top_level_args was already correct) — but it manufactured a large volume of false
    args-count mismatches on the language-crucible python corpus, where most real functions use type
    hints, defaults, or *args/**kwargs.
  • args_exact_match rises from 63.0% (1868/2966) to 98.6% (2926/2966). No regressions on the other
    gated metrics (found_functions/extra_functions/found_classes/extra_classes untouched by
    this branch).
  • Baseline regenerated via --regenerate.

Fixes #1524.

Test plan

  • Verified fix directly against a hand-built repro (def foo(a, b: int, c=1, d: str = "x", *args, e, **kwargs): measured 2 → 7; def bar(a, /, b, *, c, **kwargs): measured 3 → 4)
  • python tests/tools/tree_sitter_accuracy_audit.py --lang python — no regressions, args_exact_match 1868 → 2926
  • python tests/ruff_audit.py --ci — no new findings
  • python tests/mypy_audit.py --ci — no new errors
  • Not a parsing-logic change (test tooling only) — no differential scan / golden master regen needed

🤖 Generated with Claude Code

tree_sitter_accuracy_audit.py's counted_types whitelist for the
top-level `parameters`-field branch was built around JS/C-family node
type names and never widened for python, whose grammar wraps every
typed, defaulted, or splat parameter in its own node type
(typed_parameter, default_parameter, typed_default_parameter,
list_splat_pattern, dictionary_splat_pattern). Only fully bare
identifiers were ever counted, undercounting real arity for most
real-world Python signatures. args_exact_match on the language-crucible
python corpus rises from 63.0% (1868/2966) to 98.6% (2926/2966), no
regressions on the other gated metrics.

Fixes #1524.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown
Contributor

🐦‍⬛ Muninn Security Scan

✅ No security issues found.

🐦‍⬛ Powered by Muninn · Skald Lab

@squid-protocol
squid-protocol merged commit 0b071d3 into main Aug 14, 2026
30 checks passed
@squid-protocol
squid-protocol deleted the fix/python-tree-sitter-args-node-types branch August 14, 2026 01:00
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.

tree_sitter_accuracy_audit.py: python's _get_param_count only counts bare identifiers, undercounting real arity

1 participant