Repository navigation
feat(signature): read the header, bind call arguments, render the rewrite (#1533, 3/9) - #2162
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Merge Risk: ⚪ Minimal · up to
|
6af7113 to
0828870
Compare
|
|
|
@greptile review |
Unit tests for signature_bind on real tree-sitter parses: plain parameter specs and refusals, receiver handling (static, classmethod, unusual name), body renames and the scopes that refuse them, binding a call's arguments to old indexes, rendering the new argument list, folding nested edits, hierarchy agreement and the definition's own edits.
Each assertion now checks one thing, and the pytest.raises blocks hold only the call expected to raise.
…/pr-3 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016xpVRsxnpLfjsPc7qrjoyy
…/pr-3 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016xpVRsxnpLfjsPc7qrjoyy
Reordering parameters used to reorder positional values, so `(a, b)` to `(b, a)` turned `f(first(), second())` into `f(second(), first())` and ran `second()` first. Values now stay positional only while they keep the order the site wrote them; the rest go by keyword in that order. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Y9fLCP6Y2cycV2iRvFM8Ah
#2162 now spells reordered values by keyword in their written order, so the dry run renders `helper(a=3, b='z')` rather than `helper('z', 3)`. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Y9fLCP6Y2cycV2iRvFM8Ah
Follows #2162: reordered values are spelled by keyword in the order the site wrote them, so a reorder never changes evaluation order. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Y9fLCP6Y2cycV2iRvFM8Ah
…uns code Names and plain literals evaluate the same in any order while nothing runs between them, so a site passing only those keeps the positional reorder #1533 asks for: `helper(2, 'x')` becomes `helper('x', 2)`. A site with a call, attribute or f-string keeps its written order by keyword. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Y9fLCP6Y2cycV2iRvFM8Ah
…ents #2162 reorders a site positionally again when its values are only names and plain literals, so the dry run renders `helper('z', 3)` once more. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Y9fLCP6Y2cycV2iRvFM8Ah
…ally Follows #2162: only a site with a value that runs code keeps its written order by keyword. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Y9fLCP6Y2cycV2iRvFM8Ah
Sonar flags `_positional_run` over the cognitive-complexity limit; the leading run and the cut before keyword values are now separate helpers, with the same behaviour. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Y9fLCP6Y2cycV2iRvFM8Ah
|
Generated by Claude Code |
|
@greptile review |
This comment has been minimized.
This comment has been minimized.
…meter A class pattern's keyword (`case Point(a=a)`) names an attribute of the subject, and the trailing parts of a dotted value pattern (`case Color.a:`) are attribute names too. The body rename treated both as uses of the parameter, so renaming `a` to `z` produced `case Point(z=z)`, which no longer matches objects with an `a` attribute. Only the capture and the head of a dotted name are references now; the same check stops those labels counting as reads of the new name. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Y9fLCP6Y2cycV2iRvFM8Ah
|
|
@greptile review |
#2162 now spells reordered values by keyword in their written order, so the dry run renders `helper(a=3, b='z')` rather than `helper('z', 3)`. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Y9fLCP6Y2cycV2iRvFM8Ah
…ents #2162 reorders a site positionally again when its values are only names and plain literals, so the dry run renders `helper('z', 3)` once more. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Y9fLCP6Y2cycV2iRvFM8Ah
#2162 now spells reordered values by keyword in their written order, so the dry run renders `helper(a=3, b='z')` rather than `helper('z', 3)`.
…ents #2162 reorders a site positionally again when its values are only names and plain literals, so the dry run renders `helper('z', 3)` once more.
vitali87#2162 now spells reordered values by keyword in their written order, so the dry run renders `helper(a=3, b='z')` rather than `helper('z', 3)`.
…ents vitali87#2162 reorders a site positionally again when its values are only names and plain literals, so the dry run renders `helper('z', 3)` once more.
Follows vitali87#2162: reordered values are spelled by keyword in the order the site wrote them, so a reorder never changes evaluation order.
…ally Follows vitali87#2162: only a site with a value that runs code keeps its written order by keyword.



Summary
codebase_rag/editing/signature_bind.py. It reads a Python definition's header with tree-sitter, finds the parameters the body reads or references, binds each call site's arguments to the new parameter list, and renders the rewritten definition and call text.constants/cli.py(feat(signature): contract expectation, shared call-site helpers and constants for change_signature (#1533, 1/9) #2163).SignatureChangerdoes, and feat(signature): expose change_signature through the CLI and MCP, with docs (#1533, 5/9) #2164 exposes that ascgr change-signature.Demo
No user-visible change: adds internal helpers for
change_signature, which #2164 exposes ascgr change-signature.Type of Change
Related Issues
Part of #1533 (split from #1912; stack: #2163 → #2161 → #2162 → #2166 → #2164 → #2169 → #2168 → #2165 → #2167).
Test Plan
Unit tests pass (
make test-paralleloruv run pytest -n auto -m "not integration")New tests added
Integration tests pass (
make test-integration, requires Docker)Manual testing (describe below)
uv run python -m pytest codebase_rag/tests/test_signature_bind.py -p no:randomly -qatb798f5720: 44 passed.The full suite was not run locally. The CI Unit Tests run at
b798f5720was cancelled before it finished.Checklist
make pre-commit)# type: ignore,cast(),Any, orobjecttype hintsSKIP=no-commit-to-branch pre-commit run --from-ref 34d367d4f --to-ref b798f5720(ruff, ruff-format, ty, bandit, generate-readme and the file hygiene hooks): passed. The unit-suite step ofmake pre-commitwas not run locally.Unchecked items:
signature_bind.pybuilds Python syntax inline in f-strings (f"{spec.name}={value}", the parenthesised argument list, andrf"\b{re.escape(old)}\b"). Its messages come fromconstants/cli.py.signature_bind.pydeclares alabel: objectparameter.Files changed
codebase_rag/editing/signature_bind.pycodebase_rag/tests/test_signature_bind.pyDiff stats
+870 additions, -0 deletions (870 LOC)
Dependencies
This PR depends on:
pr-2Dependency graph
Merge in this order:
Summary by CodeRabbit