`findit.find_implementations` on method call finds implementation for different subclass
維護者通常 5 天內回覆
還沒有人認領這個 Issue。
評估
- 難度
- 4/5
- 預估耗時
- 3-5 天
- 新手友好度
- 30/100
- Issue 類型
- 缺陷
- 描述清晰度
- 基本清楚
- 活躍度
- 停滯
- 技術堆疊
- python
研究方向
The reproduction is in example.py and bug.py using rope.contrib.findit.find_implementations on the a.f() call at line 10. Start by reading find_implementations in rope/contrib/findit.py and how it resolves the type of a to its defining class. Done means the call resolves to A.f and not B.f, with the reproduction printing line 2.
由索引模型根據 Issue 內容生成。
描述
Describe the bug
Running Rope's rope.contrib.findit.find_implementations on the a.f() call in a file like
class A:
def f(self):
return 1
class B(A):
def f(self):
return 2
a: A = A()
a.f()
makes it return the position of B.f, which has nothing to do with that call as it's only related to A.
To Reproduce
Save the snippet above as example.py and run this script (let's call it bug.py) in the same folder:
from rope.base.project import Project
from rope.contrib.findit import find_implementations
project = Project(".")
resource = project.get_file("example.py")
pymodule = project.get_pymodule(resource)
call_offset = pymodule.lines.get_line_start(10) + 2 # l. 10: a.f()
for loc in find_implementations(project, resource, call_offset):
print(loc.lineno)
Expected behavior:
It should output 2, as line 2 is where A.f which is being called here is defined.
Actual behavior:
It outputs (line) 6, which is where B.f is defined. B.f has nothing to do with the call a.f, except that it happens to be an implementation of A.f as well (but that is not the implementation we're calling!).
Screenshots
None required.
Editor information (please complete the following information):
No editor needed to reproduce.
Additional context
This was found while trying to use findit.find_implementations to add support for the LSP textDocument/implementation capability to python-lsp-server:
- 主要語言
- Python
- 星號
- 2.2k
- 分支
- 197
- 平均合併
- 2 天 17 小時
- 30 天內合併 PR
- 11
環境準備
- 沒有 Dockerfile 或 Docker Compose 檔案
- 有 Pull Request 範本
- 閱讀貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
python-rope/rope 的其他 Issue
-
LocalToField doesn't validate the offset until get_changes()可能已有人在做 @Narek-Khachikyan 今天認領。 未關閉
難度 1/5 1-3 小時 新手友好度 88/100
python-rope/rope#927 ·
維護者通常 5 天內回覆
-
simplify.real_code blanks t-strings, so renames inside them edit the wrong offset可能已有人在做 @sean0407 於 15 天前認領。 未關閉
難度 2/5 1-3 小時 新手友好度 83/100
python-rope/rope#913 ·
維護者通常 5 天內回覆
-
Implement nonlocal variables scoping rule for rename refactor可能已有人在做 @ryanchou1994 於 2 天前認領。 未關閉bug
難度 4/5 3-5 天 新手友好度 48/100
python-rope/rope#935 ·
維護者通常 5 天內回覆
-
難度 4/5 3-5 天 新手友好度 30/100
python-rope/rope#925 ·
維護者通常 5 天內回覆
-
Extract method/variable and introduce parameter don't check whether the new name is already in use可能已有人在做 @aliassar 於 3 天前認領。 未關閉
難度 3/5 1-2 天 新手友好度 62/100
python-rope/rope#924 · 2 則留言 ·
維護者通常 5 天內回覆
相似的 Issue
-
難度 2/5 1-3 小時 新手友好度 77/100
-
needs-triage tooling
難度 1/5 1 小時以內 新手友好度 90/100
neilsh/stunt-reel#317 ·
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 85/100
TandoorRecipes/recipes#4926 ·
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 75/100
PyTomography/PyTomography#431 ·
維護者通常 1 天內回覆
-
bug
難度 2/5 1-3 小時 新手友好度 74/100
igormcsouza/tether#278 ·
維護者通常 1 天內回覆