python-rope / rope

a python refactoring library
GNU Lesser General Public License v3.0
1.96k stars 164 forks source link

Rename Field refactoring allows you to rename a local field with the method name #766

Closed researcher175 closed 8 months ago

researcher175 commented 8 months ago

Rename Field refactoring allows the use of the name of the recursive method in the field inside the same method. It would be nice if Rope could emit an alert to the user to confirm the operation to avoid type errors

Steps to reproduce the behavior:

  1. Code before refactoring:

    
    def pluralize(word, pos="NN", custom={}, classical=True):
    if word.endswith("'"):
        owners = pluralize(word.rstrip("'s"), pos, custom, classical)
        if owners.endswith("s"):
            return owners + "'"
    
    words = word.replace("-", " ").split(" ")
    return word.replace(words[0], pluralize(words[0], pos, custom, classical))

2. Apply the Rename Field refactoring with the new name 'pluralize' to the 'owners' field.
lieryan commented 8 months ago

Closing. Ticket merged into #779.