Skip to content

Commit

Permalink
Fix renaming kwargs when refactoring from imports
Browse files Browse the repository at this point in the history
  • Loading branch information
apmorton committed Jan 10, 2023
1 parent 5a347f8 commit 2aabd21
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion rope/refactor/importutils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ def _from_to_normal(self, pymodule, import_stmt):
if alias is not None:
imported = alias
occurrence_finder = occurrences.create_finder(
self.project, imported, pymodule[imported], imports=False
self.project, imported, pymodule[imported], imports=False, keywords=False
)
source = rename.rename_in_module(
occurrence_finder,
Expand Down
7 changes: 7 additions & 0 deletions ropetest/refactor/importutilstest.py
Original file line number Diff line number Diff line change
Expand Up @@ -903,6 +903,13 @@ def test_transforming_froms_to_normal_for_os_path(self):
changed_module = self.import_tools.froms_to_imports(pymod)
self.assertEqual("import os\nos.path.exists('.')\n", changed_module)


def test_transforming_froms_to_normal_kwarg_with_same_name(self):
self.mod.write("from os import path\nfoo(path=path.join('a', 'b'))\n")
pymod = self.project.get_pymodule(self.mod)
changed_module = self.import_tools.froms_to_imports(pymod)
self.assertEqual("import os\nfoo(path=os.path.join('a', 'b'))\n", changed_module)

def test_transform_relatives_imports_to_abs_imports_doing_nothing(self):
self.mod2.write("from pkg1 import mod1\nimport mod1\n")
pymod = self.project.get_pymodule(self.mod2)
Expand Down

0 comments on commit 2aabd21

Please sign in to comment.