Inline method refactoring applied to rich comparison methods

Abierto
#758 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
30/100
Tipo de issue
Nueva funcionalidad
Claridad
Bastante claro
Estado de actividad
Estancado
Stack tecnológico
python
Área
tooling

Línea de trabajo

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.

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

Descripción

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__'
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.