python-rope / rope

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

Rename Method refactoring allows you to rename a nested method with a parameter name #776

Closed researcher175 closed 8 months ago

researcher175 commented 8 months ago

Rename Method refactoring allows you to rename a nested method with the parameter name of the outer method. It would be nice if Rope sent an alert to avoid missing annotations

Steps to reproduce the behavior:

  1. Code before refactoring:

    
    def _calculate_tk(source):
    def c_int(x, nbits=32):
        return (x & ((1 << (nbits - 1)) - 1)) - (x & (1 << (nbits - 1)))
    
    def c_uint(x, nbits=32):
        return x & ((1 << nbits) - 1)
    
    tkk = [406398, 561666268 + 1526272306]
    b = tkk[0]
    
    d = source.encode('utf-8')
    
    def RL(a, b):
        for c in range(0, len(b) - 2, 3):
            d = b[c + 2]
            d = ord(d) - 87 if d >= 'a' else int(d)
            xa = c_uint(a)
            d = xa >> d if b[c + 1] == '+' else xa << d
            a = a + d & 4294967295 if b[c] == '+' else a ^ d
        return c_int(a)
    
    a = b
    
    for di in d:
        a = RL(a + di, "+-a^+6")
    
    a = RL(a, "+-3^+b+-f")
    a ^= tkk[1]
    a = a if a >= 0 else ((a & 2147483647) + 2147483648)
    a %= pow(10, 6)
    
    tk = '{0:d}.{1:d}'.format(a, a ^ b)
    return tk

2. Apply the Rename Method refactoring with the new name 'source' to the method 'c_int'
lieryan commented 8 months ago

Closing. Ticket merged into #779.