Repository navigation
fix: record attribute definition index for assignment and deletion targets - #5181
Closed
Aayushyaash wants to merge 2 commits into
Closed
Aayushyaash wants to merge 2 commits into
Aayushyaash wants to merge 2 commits into
Conversation
Contributor
|
This pull request has been imported. If you are a Meta employee, you can view this in D124412572. (Because this pull request was imported automatically, there will not be any future comments.) |
|
According to mypy_primer, this change doesn't affect type check results on a corpus of open source code. ✅ |
kinto0
approved these changes
Oct 13, 2026
kinto0
left a comment
Contributor
There was a problem hiding this comment.
thanks for the PR! it seems like this fixes it. let me do some further testing (make sure test failed before trunk, count how many new attribute indexes we have)
Contributor
|
This pull request has been merged in 8dc10f9. |
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
When triggering a rename (
textDocument/rename) on a class attribute, attribute reads (r.attr) and assignments toself.attrare renamed properly, but assignments through an instance (r.attr = val) and attribute deletions (del r.attr) are skipped across files.Previously, attribute reads recorded references in
Index.externally_defined_attribute_referencesviarecord_attribute_definition_indexinexpr.rs, but attribute assignments and deletions insolve.rsomitted this step.This PR adds
record_attribute_definition_indexcalls for attribute assignments and deletions so these references are included in rename and reference resolution.Fixes #5082
Test Plan
Added an LSP interaction test in
pyrefly/lib/test/lsp/lsp_interaction/rename.rsverifying that renaming a class attribute across modules updates attribute assignments and deletions, along with the declaration and other references.Validation:
cargo test test_rename_cross_file_attribute_assignment_and_deletion cargo clippy -p pyrefly python3 test.py --no-test --no-tensor-shapes --no-conformance --no-jsonschema --no-extension