The Inline Method refactoring removed an import

オープン
#826 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 7 日以内に返信

まだ誰も着手していません。

評価

難易度
3/5
見積もり時間
半日
初心者へのやさしさ
55/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
停滞
技術スタック
python
領域
tooling

調査の方向性

Start with the reproduction: apply Inline Method to StringlikeMixin.find in mixins.py, then compare the test_mixins.py imports before and after. The bug is that from nose.tools import * disappears, so the inlined assert_equal call breaks. Find where rope's inline refactoring rewrites imports in the edited module, and check whether it drops names that the rewritten code still uses. Done means test_mixins.py keeps the nose import after inlining and the test runs.

索引モデルが issue の本文から書いたものです。

説明

bug

The Inline Method refactoring removed an import from the test file, causing an error when the test file is run.

Steps to reproduce the behavior:

  1. Code before refactoring:
-- mixins.py
from __future__ import unicode_literals

class StringlikeMixin(object):
    def __init__(self, text):
        self._text = text

    def _strkey(self):
        return self._text

    def find(self, sub, start=0, end=None):
        if end is None:
            end = len(self._strkey())
        return self._strkey().find(sub, start, end)

-- test_mixins.py
from __future__ import unicode_literals, absolute_import
from nose.tools import *
from mixins import StringlikeMixin


def test_find():
    text = 'Beautiful is better than ugly.'
    blob = StringlikeMixin(text)

    assert_equal(
        blob.find('better', 5, len(blob._strkey())),
        text.find('better', 5, len(text))
    )
  1. Apply the inline method to StringlikeMixin.find

  2. Code after refactoring:

-- mixins.py
from __future__ import unicode_literals

class StringlikeMixin(object):
    def __init__(self, text):
        self._text = text

    def _strkey(self):
        return self._text


-- test_mixins.py
from __future__ import unicode_literals, absolute_import

from mixins import StringlikeMixin

def test_find():
    text = 'Beautiful is better than ugly.'
    blob = StringlikeMixin(text)

    assert_equal(
        blob._strkey().find('better', 5, len(blob._strkey())),
        text.find('better', 5, len(text))
    )

主要言語
Python
スター
2.2k
フォーク
197
平均マージ
2日 13時間
マージ済み PR(30日)
5

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

python-rope/rope のほかの issue

python-rope/rope の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。