Inline method refactoring inserts an unexpected argument

Abierto
#757 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
4/5
Tiempo estimado
3-5 días
Aptitud para principiantes
35/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Estancado
Stack tecnológico
python
Área
devtools

Línea de trabajo

Start by reproducing the Inline Method refactoring on Word.translate in blob.py, using the call in test.py as the target. The bad output is the __0__from_lang keyword in the inlined call, so look at how rope builds argument names when it substitutes call-site arguments. Done when the inlined call reads translate_to('string', from_lang='auto', to_lang="es") with no extra argument.

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

Descripción

bug inline-refactor

Inline method refactoring inserts an unexpected argument in the method call.

Steps to reproduce the behavior:

  1. Code before refactoring:

structure:

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

blob.py:

class Word(str):

    def translate_to(self, source, from_lang='auto', to_lang='en', host=None):
        pass

    def translate(self, from_lang='auto', to="en"):
        return self.translate_to('string', from_lang=from_lang, to_lang=to)

test.py:

import main as tb
from unittest import TestCase


class WordTest(TestCase):

    def test_translate(self, mock_translate):
        mock_translate.return_value = 'gato'
        assert_equal(tb.Word("cat").translate(to="es"), "gato")

  1. Apply the Inline Method refactoring to the 'Word.translate' in 'blob.py'

  2. Expected code after refactoring:

blob.py:

class Word(str):

    def translate_to(self, source, from_lang='auto', to_lang='en', host=None):
        pass

test.py:

import main as tb
from unittest import TestCase


class WordTest(TestCase):

    def test_translate(self, mock_translate):
        mock_translate.return_value = 'gato'
        assert_equal(tb.Word("cat").translate_to('string', __0__from_lang='auto', to_lang="es"), "gato")

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.