rope icon indicating copy to clipboard operation
rope copied to clipboard

Rename refactoring doesn't rename a function's default arguments when the renamed variable is defined in the class scope

Open jonh-copin opened this issue 2 years ago • 0 comments

Applying the Rename refactoring to the following program causes runtime problems.

Steps to reproduce the behavior:

  1. Code before refactoring:
import nltk


class Word:
    PorterStemmer = nltk.stem.porter.PorterStemmer()

    def stem(self, stemmer=PorterStemmer):
        return stemmer.stem('')
  1. Apply the Rename refactoring to the variable "PorterStemmer"

  2. Expected code after refactoring:

import nltk


class Word:
    PorterStemmer_refactored = nltk.stem.porter.PorterStemmer()

    def stem(self, stemmer=PorterStemmer_refactored):
        return stemmer.stem('')
  1. In the function "stem", the parameter type is not refactored to the new name. Code after refactoring:
import nltk


class Word:
    PorterStemmer_refactored = nltk.stem.porter.PorterStemmer()

    def stem(self, stemmer=PorterStemmer):
        return stemmer.stem('')

jonh-copin avatar Apr 14 '23 11:04 jonh-copin