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 the use of a name that can not be iterable #764

Closed researcher175 closed 8 months ago

researcher175 commented 8 months ago

Rename field refactoring allows the use of post-declared methods as new names for the field. It would be nice if Rope could emit an alert to the users indicating the probable problems that could be generated if the operation continues. Python's name resolution can cause type errors during execution.

Steps to reproduce the behavior:

  1. Code before refactoring:
    
    MIN_CORPORA = ['brown']
    ADDITIONAL_CORPORA = ['movie_reviews']
    ALL_CORPORA = MIN_CORPORA + ADDITIONAL_CORPORA

def download(param): pass

def download_lite(): for each in MIN_CORPORA: download(each)

def download_all(): for each in ALL_CORPORA: download(each)

def main(): download_lite() download_all()

main()



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

Closing. Ticket merged into #779.