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

Applying the Inline Method refactoring does not add the required import. #743

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

Comments

@jonhnanthan
Copy link

jonhnanthan commented Jan 15, 2024

Steps to reproduce the behavior:

  1. Code before refactoring:

structure:
project
| - src
| -- __init__.py
| -- main.py
| -- test.py

main.py

import sys


class Base:
    def __init__(self, text):
        self.raw = text

    def split(self, sep=None, maxsplit=sys.maxsize):
        return self.raw.split(sep, maxsplit)[0]

test.py

from unittest import TestCase
from src.split_main import Base

class Test(TestCase):
    def test_split(self):
        blob = Base('Beautiful is better')
        self.assertEqual(blob.split(), ['Beautiful'])
  1. Apply the Inline Method to Base.split().

  2. Expected code after refactoring:

structure:
project
| - src
| -- __init__.py
| -- main.py
| -- test.py

main.py

class Base:
    def __init__(self, text):
        self.raw = text

test.py

import sys
from unittest import TestCase
from src.split_main import Base

class Test(TestCase):
    def test_split(self):
        blob = Base('Beautiful is better')
        self.assertEqual(blob.raw.split(None, sys.maxsize)[0], ['Beautiful'])
  1. The "import sys" is not automatically added.
@jonhnanthan jonhnanthan added the bug Unexpected or incorrect user-visible behavior label Jan 15, 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