Rename parameters across files in keyword arguments#3290
Rename parameters across files in keyword arguments#3290asukaminato0721 wants to merge 1 commit into
Conversation
|
According to mypy_primer, this change doesn't affect type check results on a corpus of open source code. ✅ |
There was a problem hiding this comment.
Pull request overview
Adds cross-file rename support for function parameters by ensuring keyword argument usages in other files are treated as references, and introduces a regression test covering this behavior (part of IDE feature tracker #2207).
Changes:
- Extend reference collection for externally-defined parameter symbols to include matching keyword-argument sites in other modules.
- Refactor keyword-argument reference matching to rely on existing
find_definition_for_keyword_argumentresults. - Add a new LSP interaction test fixture + test verifying parameter rename updates keyword arguments across files without touching unrelated calls.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
pyrefly/lib/state/lsp.rs |
Include keyword-argument references when the parameter definition lives in a different module; refactor keyword-arg resolution plumbing. |
pyrefly/lib/test/lsp/lsp_interaction/rename.rs |
Add regression test for cross-file parameter rename updating keyword arguments. |
pyrefly/lib/test/lsp/lsp_interaction/test_files/rename_parameter_keywords_across_files/pyrefly.toml |
Configure test workspace search path for cross-file import resolution. |
pyrefly/lib/test/lsp/lsp_interaction/test_files/rename_parameter_keywords_across_files/fileA.py |
Defines the target function/parameter for rename. |
pyrefly/lib/test/lsp/lsp_interaction/test_files/rename_parameter_keywords_across_files/fileB.py |
Contains both a relevant keyword-arg call and an unrelated one to validate disambiguation. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| &self, | ||
| handle: &Handle, | ||
| definition_range: TextRange, | ||
| definition_module: &Module, | ||
| expected_name: &Name, |
| definition_range: TextRange, | ||
| definition_module: &Module, | ||
| expected_name: &Name, | ||
| ) -> Option<Vec<TextRange>> { |
|
oh, this also handle the name in like comments, strings. |
|
This pull request has been automatically marked as stale because it has not had recent activity for more than 2 weeks. If you are still working on this this pull request, please add a comment or push new commits to keep it active. Otherwise, please unassign yourself and allow someone else to take over. Thank you for your contributions! |
|
oops - missed this. would you mind making the issue title / summary more clear as to why these are both necessary and if they don't overlap? |
853ee07 to
926ec3e
Compare
|
so it looks like this branch will be rebased / dropped? can you combine these PRs or decide which one you want us to review? |
|
suppressed by #2484 |
Summary
Part of #2207.
This PR fixes parameter rename across files when the external use is a keyword argument. For example, renaming
paramin:now also updates the caller-side keyword in another file:
The implementation adds keyword-argument references to the external reverse-dependency reference path. It does not rename keyword textually: each matching
param=candidate resolves its callee, refines that callee back to the actual parameter definition, and only edits the keyword when the refined parameter range matches the parameter being renamed.Relationship to branch
1583Branch
1583overlaps with this PR. It targets the same cross-file parameter-keyword rename behavior and adds a similar LSP regression fixture. It is broader than this PR because it also carries fallback logic around external-definition range/line matching.This PR is the narrower version: it only wires parameter keyword-argument references into the existing external reverse-dependency lookup. If
1583lands first, this branch should be rebased or dropped rather than landed independently with duplicate coverage.Test Plan
cargo test rename::test_renamepython3 test.py --no-test --no-conformance --no-jsonschema