Inline method refactoring applied to rich comparison methods

Ouverte
#758 0 commentaires 0 réactions 0 personnes assignées Voir sur GitHub

Les mainteneurs répondent en général sous 7 jours

Personne n'a encore pris cette issue.

Évaluation

Difficulté
3/5
Temps estimé
1-2 jours
Accessibilité débutants
30/100
Type d'issue
Fonctionnalité
Clarté
Plutôt claire
Activité
À l'abandon
Stack technique
python
Domaine
tooling

Piste de recherche

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.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Description

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__'
Langage dominant
Python
Étoiles
2.2k
Forks
197
Merge moyen
2 j 13 h
PR mergées (30 j)
5

Préparer son environnement

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Autres issues de python-rope/rope

Toutes les issues de python-rope/rope

Issues similaires

Plus d'issues Python

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.