Applying the Inline Method refactoring does not add the required import.
维护者通常 7 天内回复
还没有人认领这个 Issue。
评估
调研方向
Reproduce with the two files in the report: src/main.py defines Base.split with the default argument sys.maxsize, and src/test.py calls it, so inlining should copy that default into test.py. Start from rope's Inline Method refactoring and check how it collects imports for names used in the inlined body. Done when applying the refactoring to Base.split leaves import sys at the top of test.py, and a test covers the default-argument case.
由索引模型根据 Issue 内容生成。
描述
Steps to reproduce the behavior:
- 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'])
-
Apply the Inline Method to Base.split().
-
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'])
- The "import sys" is not automatically added.
- 主要语言
- 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 天内回复
-
Extract raises IndexError or ModuleSyntaxError instead of RefactoringError for an empty or whitespace-only region可能已有人在做 @aliassar 今天认领。 未关闭
难度 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
-
Paraxial.trace returns NaN for an object at infinity when the entrance pupil is at the first surface未关闭
难度 2/5 1-3 小时 新手友好度 75/100
维护者通常 1 天内回复
-
enhancement ios launcher
难度 2/5 1-3 小时 新手友好度 70/100
维护者通常 1 天内回复
-
Substrait consumer doesn't recognise `shift_left` / `shift_right` from functions_arithmetic.yaml未关闭bug
难度 2/5 1-3 小时 新手友好度 76/100
apache/datafusion#27059 ·
维护者通常 1 天内回复
-
难度 1/5 1 小时以内 新手友好度 85/100
loteran/Arctis-Sound-Manager#368 ·
维护者通常 1 天内回复
-
feed submission
难度 2/5 1-3 小时 新手友好度 65/100
MobilityData/mobility-database-catalogs#1787 ·
维护者通常 2 天内回复