`findit.find_implementations` on method call finds implementation for different subclass
I maintainer di solito rispondono entro 7 giorni
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 30/100
- Tipo di issue
- Bug
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Ferma
- Stack tecnologico
- python
- Ambito
- developer-experience
Direzione di ricerca
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.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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:
- Lingua principale
- Python
- Stelle
- 2.2k
- Fork
- 197
- Merge medio
- 2g 13h
- PR unite (30g)
- 5
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di python-rope/rope
-
Difficoltà 1/5 1-3 ore Idoneità per principianti 88/100
python-rope/rope#927 ·
I maintainer di solito rispondono entro 7 giorni
-
Extract raises IndexError or ModuleSyntaxError instead of RefactoringError for an empty or whitespace-only regionForse già presa @aliassar l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
python-rope/rope#926 ·
I maintainer di solito rispondono entro 7 giorni
-
simplify.real_code blanks t-strings, so renames inside them edit the wrong offsetForse già presa @sean0407 l’ha presa 11 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 83/100
python-rope/rope#913 ·
I maintainer di solito rispondono entro 7 giorni
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 30/100
python-rope/rope#925 ·
I maintainer di solito rispondono entro 7 giorni
-
Extract method/variable and introduce parameter don't check whether the new name is already in useAperta
Difficoltà 3/5 1-2 giorni Idoneità per principianti 62/100
python-rope/rope#924 ·
I maintainer di solito rispondono entro 7 giorni
Tutte le issue di python-rope/rope
Issue simili
-
Backend issue lists report in-patch warnings and out-of-patch errors as not publishableForse già presa @RaphaelFakhri l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
mozilla/code-review#3794 ·
I maintainer di solito rispondono entro 1 giorno
-
[oblt-aw][autodoc] Update docs that still describe the security registry as emptyForse già presa @github-actions l’ha presa oggi. Aperta
Difficoltà 1/5 1-3 ore Idoneità per principianti 85/100
I maintainer di solito rispondono entro 1 giorno
-
[Bug] adb backup script reports "Done" & exits 0 when the backup failsForse già presa @bhattmanthan l’ha presa oggi. Apertarequest-issue-assignment
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
OWASP/mastg#4034 · 5 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
agent-ui bug p2
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
I maintainer di solito rispondono entro 1 giorno
-
correction metadata
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 72/100
acl-org/acl-anthology#10768 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno