Skip to content

Commit

Permalink
fix: avoid changing import list if old name is new name
Browse files Browse the repository at this point in the history
  • Loading branch information
akx authored and browniebroke committed Oct 16, 2020
1 parent 0372933 commit c3fecb3
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions django_codemod/visitors/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,11 @@ def gen_new_imported_names(
for import_alias in old_names:
if not self.old_name or import_alias.evaluated_name == self.old_name:
self.context.scratch[self.ctx_key_imported_as] = import_alias.asname
if self.simple_rename:
self.add_new_import(import_alias.evaluated_name)
else:
yield import_alias
if self.rename_from != self.rename_to:
if self.simple_rename:
self.add_new_import(import_alias.evaluated_name)
continue
yield import_alias

def tidy_new_imported_names(self, new_names):
"""Tidy up the updated list of imports"""
Expand Down

0 comments on commit c3fecb3

Please sign in to comment.