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

Aberta
#686 0 comentários 0 reações 0 responsáveis Ver no GitHub

Mantenedores costumam responder em até 7 dias

Ninguém assumiu esta issue ainda.

Avaliação

Dificuldade
3/5
Tempo estimado
1-2 dias
Facilidade para iniciantes
50/100
Tipo de issue
Bug
Clareza
Claramente especificada
Status de atividade
Estagnada
Stack de tecnologia
python
Domínio
tooling

Direção de pesquisa

Reproduce the issue by running the Rename refactoring on the PorterStemmer class attribute in the Word example, and confirm the default argument stemmer=PorterStemmer in stem is left unchanged. Then trace why occurrence search finds the class-level assignment but not the default-argument reference in the function signature. Done when the default argument is renamed along with the attribute and the same program runs without a NameError.

Escrita pelo modelo de indexação a partir do texto da issue.

Descrição

bug rename-refactor

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('')
Linguagem predominante
Python
Estrelas
2.2k
Forks
197
Merge médio
2d 13h
PRs com merge (30d)
5

Preparar o ambiente

Primeiros passos

  1. Leia a issue inteira e depois o guia de contribuição do projeto.
  2. Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
  3. Faça um fork do repositório e trabalhe em uma branch.
  4. Abra um pull request que referencie o número da issue.

Mais de python-rope/rope

Todas as issues de python-rope/rope

Issues semelhantes

Mais issues de Python

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.