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

Abierto
#686 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 7 días

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
3/5
Tiempo estimado
1-2 días
Aptitud para principiantes
50/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Estancado
Stack tecnológico
python
Área
tooling

Línea de trabajo

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.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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('')
Lenguaje dominante
Python
Estrellas
2.2k
Forks
197
Merge medio
2 d 13 h
PR fusionados (30 d)
5

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de python-rope/rope

Todos los issues de python-rope/rope

Issues similares

Más issues de Python

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.