fix(tests): python's tree-sitter args-counter only measured bare identifiers - #1525
Merged
Merged
Conversation
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>
Contributor
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
_get_param_count()intests/tools/tree_sitter_accuracy_audit.pyresolves python'sfunction_definitionparameter list directly via the genericparameters-field branch, butthat branch's
counted_typeswhitelist only had JS/C-family node type names — none oftree-sitter-python's own per-parameter wrapper types (
typed_parameter,default_parameter,typed_default_parameter,list_splat_pattern,dictionary_splat_pattern). Only a fully barex(no type, no default) was ever counted.generic top-level branch instead of one of the special-cased fallback branches those issues
audited.
argsregex (detector.py's_count_top_level_argswas already correct) — but it manufactured a large volume of falseargs-count mismatches on the language-crucible python corpus, where most real functions use type
hints, defaults, or
*args/**kwargs.args_exact_matchrises from 63.0% (1868/2966) to 98.6% (2926/2966). No regressions on the othergated metrics (
found_functions/extra_functions/found_classes/extra_classesuntouched bythis branch).
--regenerate.Fixes #1524.
Test plan
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 → 2926python tests/ruff_audit.py --ci— no new findingspython tests/mypy_audit.py --ci— no new errors🤖 Generated with Claude Code