fix(python): args regex only balanced one level of nested parens - #1547
Merged
Conversation
#1527: python's args rule's parameter-list capture group \((?:[^()]|\([^()]*\))*\) balances exactly one level of nested parens (outer paren + one inner non-nested group). A default value with two levels of nested calls -- FastAPI's dependency-injection idiom Depends(partial(callable_gen_dependency, "x")) -- doesn't match at all, so the whole def statement is skipped and args silently defaults to 0. Extends the existing bounded-recursion idiom by one more level (still no unbounded backtracking -- same ReDoS-safety tradeoff already established for this rule, just deeper). Confirmed 12 occurrences of this exact shape in language-crucible/data/python/fastapi/tests/test_dependency_partial.py. args_exact_match: 3588 -> 3601 (python corpus), no other metric changed. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Rebased this branch onto the current main (after #1538/#1539/#1545 merged) and regenerated the target's own tree-sitter baseline, both golden masters, and the ruff line-shift baseline against the combined state. No additional code change beyond the previous commit. 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.
Fixes #1527.
Summary
Python's
argsrule's parameter-list capture group\((?:[^()]|\([^()]*\))*\)balances exactly one level of nested parens (outer paren + one inner non-nested group). A default value with two levels of nested calls -- FastAPI's dependency-injection idiomDepends(partial(callable_gen_dependency, "x"))-- doesn't match at all, so the wholedefstatement is skipped by theargsregex andargs_countsilently defaults to 0.Fix extends the existing bounded-recursion idiom by one more level (still no unbounded backtracking -- same ReDoS-safety tradeoff already established for this rule, just one level deeper). Confirmed 12 occurrences of this exact shape in
language-crucible/data/python/fastapi/tests/test_dependency_partial.py.Numbers
args_exact_match: 3588 -> 3601 (python corpus). No other metric changed -- purely additive fix.Test plan
pytest tests/extraction/languages/test_python.py tests/extraction/languages/test_python_strict.py-- 153 passedtree_sitter_accuracy_audit.py --all --ci-- clean across all 31 languagescrucible_check.py --mode both-- PASS/PASSaudit_check.py --ci-- all clear🤖 Generated with Claude Code