Rename Method refactoring does not change the calls of the renamed method.

Aperta
#772 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 7 giorni

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
35/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Ferma
Stack tecnologico
python
Ambito
devtools

Direzione di ricerca

Reproduce with the two-file example: main/blob.py defines WordList.count and test/test.py calls it, first with a positional argument and then with case_sensitive=True. Rename the method to start_index through rope's rename-method refactoring and check which call sites in the test are left unchanged. Done means every call to WordList.count in the test is renamed, matching the expected output in the issue. Finding those call sites depends on rope's type inference for subclasses of list, so start there.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

bug rename-refactor

Rename Method refactoring does not change the calls of the renamed method.
In the example, the call to the method in the test file must be renamed to the new name to avoid unexpected parameter calling the method from the superclass

  1. Steps to reproduce the behavior:

structure

-- main
---- blob.py
-- test
---- test.py

blob.py:

class WordList(list):

    def count(self, strg, case_sensitive=False, *args, **kwargs):
        return None

test.py:

from unittest import TestCase
from main import blobl as tb


class WordListTest(TestCase):

    def test_count(self):
        wl = tb.WordList(['monty', 'python', 'Python', 'Monty'])
        self.assertEqual(wl.count('monty'), None)
        self.assertEqual(wl.count('monty', case_sensitive=True), None)

  1. Apply the Rename Method refactoring with the new name 'start_index' to the method 'WordList.count'

  2. Expected code after refactoring:

structure:

-- main
---- blob.py
-- test
---- test.py

blob.py:

class WordList(list):

    def start_index(self, strg, case_sensitive=False, *args, **kwargs):
        return None

test.py:

from unittest import TestCase
from main import blobl as tb


class WordListTest(TestCase):

    def test_count(self):
        wl = tb.WordList(['monty', 'python', 'Python', 'Monty'])
        self.assertEqual(wl.count('monty'), None)
        self.assertEqual(wl.start_index('monty', case_sensitive=True), None)

  1. Not all uses of the touched method are changed
Lingua principale
Python
Stelle
2.2k
Fork
197
Merge medio
2g 13h
PR unite (30g)
5

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di python-rope/rope

Tutte le issue di python-rope/rope

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.