Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inline method refactoring inserts an unexpected argument #757

Open
jonhnanthan opened this issue Feb 26, 2024 · 0 comments
Open

Inline method refactoring inserts an unexpected argument #757

jonhnanthan opened this issue Feb 26, 2024 · 0 comments
Labels
bug Unexpected or incorrect user-visible behavior inline-refactor

Comments

@jonhnanthan
Copy link

jonhnanthan commented Feb 26, 2024

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")
@jonhnanthan jonhnanthan added the bug Unexpected or incorrect user-visible behavior label Feb 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Unexpected or incorrect user-visible behavior inline-refactor
Projects
None yet
Development

No branches or pull requests

2 participants