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

Offen
#686 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Maintainer antworten meist innerhalb von 7 Tagen

Dieses Issue hat noch niemand übernommen.

Bewertung

Schwierigkeit
3/5
Geschätzter Aufwand
1-2 Tage
Anfängerfreundlichkeit
50/100
Issue-Typ
Bug
Klarheit
Klar beschrieben
Aktivitätsstatus
Veraltet
Tech-Stack
python
Bereich
tooling

Rechercherichtung

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.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

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('')
Vorherrschende Sprache
Python
Sterne
2.2k
Forks
197
Ø Merge
2 T. 13 Std.
Gemergte PRs (30 T.)
5

Entwicklungsumgebung

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus python-rope/rope

Alle Issues in python-rope/rope

Ähnliche Issues

Weitere Issues zu Python

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.