ChangeImport: rewrite qualified references when old_name is specified#6760
Merged
knutwannheden merged 1 commit intomainfrom Feb 19, 2026
Merged
ChangeImport: rewrite qualified references when old_name is specified#6760knutwannheden merged 1 commit intomainfrom
ChangeImport: rewrite qualified references when old_name is specified#6760knutwannheden merged 1 commit intomainfrom
Conversation
f158123 to
c2460a5
Compare
c2460a5 to
341a2ef
Compare
timtebeek
reviewed
Feb 18, 2026
timtebeek
approved these changes
Feb 18, 2026
ChangeImport: rewrite qualified references when old_name is specified
8de96ff to
f6df7b1
Compare
ChangeImport: rewrite qualified references when old_name is specifiedChangeImport: rewrite qualified references when old_name is specified
When old_name is set, ChangeImport now also handles the `import X` / `X.name()` pattern by rewriting qualified references and managing direct imports. Supports aliased imports (`import X as f` / `f.name()`). Type attribution is updated on rewritten nodes (Identifier._type, MethodInvocation._method_type). Also fixes two pre-existing bugs: - AddImport: insertion point now considers standalone Import nodes - RemoveImport: UsageCollector now skips standalone Import identifiers
f6df7b1 to
c9f4c99
Compare
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
old_nameis set,ChangeImportnow also rewrites qualified references (X.name()→Y.name()) and manages direct imports (import X→import Y)import X as f/f.name()→import Y/Y.name())Identifier._type,MethodInvocation._method_type)AddImport(insertion point) andRemoveImport(usage collection) for standaloneImportnodesTest plan
test_change_importtests pass