Inline method refactoring applied to rich comparison methods

Aperta
#758 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à
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
30/100
Tipo di issue
Funzionalità
Chiarezza
Abbastanza chiara
Stato di attività
Ferma
Stack tecnologico
python
Ambito
tooling

Direzione di ricerca

Reproduce the issue by applying Inline Method to GFG.__lt__ in the snippet from the issue body, which calls self._compare with a lambda comparison. Find the inline-method refactoring code in rope and see where it could detect that the target is a rich comparison method. Done means applying the refactoring to such a method shows a user-facing warning, and this is confirmed by a test. The issue has no comments and no maintainer decision on what the alert should look like, so ask before building it.

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

Descrizione

bug inline-refactor

Inline method refactoring allows for rich comparison methods.
It would be nice if Rope sent an alert to the user to avoid applying the transformation to rich comparison methods.

Steps to reproduce the behavior:

  1. Code before refactoring:
class GFG:
    def __init__(self, Marks):
        self.Marks = Marks

    def _cmpkey(self):
        return self.Marks

    def _compare(self, other, method):
        try:
            return method(self._cmpkey(), other._cmpkey())
        except (AttributeError, TypeError):
            return NotImplemented

    def __lt__(self, other):
        return self._compare(other, lambda s, o: s < o)

student1_marks = GFG(90)
student2_marks = GFG(88)

print(student1_marks < student2_marks)
print(student2_marks < student1_marks)

  1. Apply the Inline Method refactoring to 'GFG.__lt__'
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.