Rename Method refactoring does not change the calls of the renamed method.

未关闭
#772 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 7 天内回复

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
35/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
停滞
技术栈
python
领域
devtools

调研方向

Reproduce with the two-file example: main/blob.py defines WordList.count and test/test.py calls it, first with a positional argument and then with case_sensitive=True. Rename the method to start_index through rope's rename-method refactoring and check which call sites in the test are left unchanged. Done means every call to WordList.count in the test is renamed, matching the expected output in the issue. Finding those call sites depends on rope's type inference for subclasses of list, so start there.

由索引模型根据 Issue 内容生成。

描述

bug rename-refactor

Rename Method refactoring does not change the calls of the renamed method.
In the example, the call to the method in the test file must be renamed to the new name to avoid unexpected parameter calling the method from the superclass

  1. Steps to reproduce the behavior:

structure

-- main
---- blob.py
-- test
---- test.py

blob.py:

class WordList(list):

    def count(self, strg, case_sensitive=False, *args, **kwargs):
        return None

test.py:

from unittest import TestCase
from main import blobl as tb


class WordListTest(TestCase):

    def test_count(self):
        wl = tb.WordList(['monty', 'python', 'Python', 'Monty'])
        self.assertEqual(wl.count('monty'), None)
        self.assertEqual(wl.count('monty', case_sensitive=True), None)

  1. Apply the Rename Method refactoring with the new name 'start_index' to the method 'WordList.count'

  2. Expected code after refactoring:

structure:

-- main
---- blob.py
-- test
---- test.py

blob.py:

class WordList(list):

    def start_index(self, strg, case_sensitive=False, *args, **kwargs):
        return None

test.py:

from unittest import TestCase
from main import blobl as tb


class WordListTest(TestCase):

    def test_count(self):
        wl = tb.WordList(['monty', 'python', 'Python', 'Monty'])
        self.assertEqual(wl.count('monty'), None)
        self.assertEqual(wl.start_index('monty', case_sensitive=True), None)

  1. Not all uses of the touched method are changed
主要语言
Python
星标
2.2k
派生
197
平均合并
2 天 13 小时
30 天内合并 PR
5

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

python-rope/rope 的其他 Issue

查看 python-rope/rope 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。