rope icon indicating copy to clipboard operation
rope copied to clipboard

Rename Field changes the import and adds a nonexistent name.

Open jonh-copin opened this issue 1 month ago • 0 comments

Rename Field changes the import and adds a nonexistent name.

Steps to reproduce the behavior:

  1. Code before refactoring:
-- app.py
from __future__ import print_function

from compat import izip

def pairs(seq1, seq2):
    return list(izip(seq1, seq2))

if __name__ == "__main__":
    print(pairs([1, 2, 3], [4, 5, 6]))

-- compat.py
from __future__ import print_function
import sys

PY2 = (sys.version_info[0] == 2)

if PY2:
    from itertools import imap, izip
else:
    imap = map
    izip = zip

__all__ = ["imap", "izip"]
  1. Apply the rename field to app.py.izip

  2. Code after refactoring:

-- app.py
from __future__ import print_function

from compat import implements_to_string

def pairs(seq1, seq2):
    return list(implements_to_string(seq1, seq2))

if __name__ == "__main__":
    print(pairs([1, 2, 3], [4, 5, 6]))

-- compat.py
from __future__ import print_function
import sys

PY2 = (sys.version_info[0] == 2)

if PY2:
    from itertools import imap, implements_to_string
else:
    imap = map
    implements_to_string = zip

__all__ = ["imap", "implements_to_string"]

jonh-copin avatar Nov 24 '25 19:11 jonh-copin