Inline method refactoring inserts an unexpected argument

Aberta
#757 0 comentários 0 reações 0 responsáveis Ver no GitHub

Mantenedores costumam responder em até 7 dias

Ninguém assumiu esta issue ainda.

Avaliação

Dificuldade
4/5
Tempo estimado
3-5 dias
Facilidade para iniciantes
35/100
Tipo de issue
Bug
Clareza
Claramente especificada
Status de atividade
Estagnada
Stack de tecnologia
python
Domínio
devtools

Direção de pesquisa

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.

Escrita pelo modelo de indexação a partir do texto da issue.

Descrição

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")

Linguagem predominante
Python
Estrelas
2.2k
Forks
197
Merge médio
2d 13h
PRs com merge (30d)
5

Preparar o ambiente

Primeiros passos

  1. Leia a issue inteira e depois o guia de contribuição do projeto.
  2. Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
  3. Faça um fork do repositório e trabalhe em uma branch.
  4. Abra um pull request que referencie o número da issue.

Mais de python-rope/rope

Todas as issues de python-rope/rope

Issues semelhantes

Mais issues de Python

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.