The Inline Method refactoring removed an import
维护者通常 7 天内回复
还没有人认领这个 Issue。
评估
调研方向
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 内容生成。
描述
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:
- 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))
)
-
Apply the inline method to
StringlikeMixin.find -
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 小时
- 30 天内合并 PR
- 5
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
python-rope/rope 的其他 Issue
-
难度 1/5 1-3 小时 新手友好度 88/100
python-rope/rope#927 ·
维护者通常 7 天内回复
-
难度 2/5 1-3 小时 新手友好度 78/100
python-rope/rope#926 ·
维护者通常 7 天内回复
-
simplify.real_code blanks t-strings, so renames inside them edit the wrong offset可能已有人在做 @sean0407 于 10 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 83/100
python-rope/rope#913 ·
维护者通常 7 天内回复
-
难度 4/5 3-5 天 新手友好度 30/100
python-rope/rope#925 ·
维护者通常 7 天内回复
-
Extract method/variable and introduce parameter don't check whether the new name is already in use未关闭
难度 3/5 1-2 天 新手友好度 62/100
python-rope/rope#924 ·
维护者通常 7 天内回复
相似的 Issue
-
难度 1/5 1 小时以内 新手友好度 78/100
521xueweihan/HelloGitHub#4237 ·
-
bug
难度 2/5 1-3 小时 新手友好度 78/100
jejjohnson/gaussx#721 ·
维护者通常 1 天内回复
-
mock-core-configs/etc/mock/rocky-10-riscv64.cfg contains the wrong architecture in config_opts['root']可能已有人在做 @jasonmontleon 于 4 天前认领。 未关闭
难度 1/5 1 小时以内 新手友好度 94/100
rpm-software-management/mock#1834 ·
-
难度 1/5 1 小时以内 新手友好度 75/100
elastic/elastic-otel-python#683 ·
维护者通常 1 天内回复
-
ci-rerun: collect.py fails a whole pr-babysit cycle on one transient GitHub 5xx and never retries未关闭follow-up
难度 2/5 1-3 小时 新手友好度 62/100
维护者通常 1 天内回复