`findit.find_implementations` on method call finds implementation for different subclass
Mantenedores costumam responder em até 7 dias
Ninguém assumiu esta issue ainda.
Avaliação
- Dificuldade
- 4/5
- Tempo estimado
- 3-5 dias
- Facilidade para iniciantes
- 30/100
- Tipo de issue
- Bug
- Clareza
- Razoavelmente clara
- Status de atividade
- Estagnada
- Stack de tecnologia
- python
- Domínio
- developer-experience
Direção de pesquisa
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.
Escrita pelo modelo de indexação a partir do texto da issue.
Descrição
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:
- Linguagem predominante
- Python
- Estrelas
- 2.2k
- Forks
- 197
- Merge médio
- 2d 13h
- PRs com merge (30d)
- 5
Preparar o ambiente
- Sem Dockerfile nem arquivo Docker Compose
- Tem um modelo de pull request
- Ler o guia de contribuição
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Mais de python-rope/rope
-
Dificuldade 1/5 1-3 horas Facilidade para iniciantes 88/100
python-rope/rope#927 ·
Mantenedores costumam responder em até 7 dias
-
Extract raises IndexError or ModuleSyntaxError instead of RefactoringError for an empty or whitespace-only regionTalvez já em andamento @aliassar assumiu há 1 dia. Aberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100
python-rope/rope#926 ·
Mantenedores costumam responder em até 7 dias
-
simplify.real_code blanks t-strings, so renames inside them edit the wrong offsetTalvez já em andamento @sean0407 assumiu há 11 dias. Aberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 83/100
python-rope/rope#913 ·
Mantenedores costumam responder em até 7 dias
-
Dificuldade 4/5 3-5 dias Facilidade para iniciantes 30/100
python-rope/rope#925 ·
Mantenedores costumam responder em até 7 dias
-
Extract method/variable and introduce parameter don't check whether the new name is already in useTalvez já em andamento @aliassar assumiu hoje. Aberta
Dificuldade 3/5 1-2 dias Facilidade para iniciantes 62/100
python-rope/rope#924 · 1 comentário ·
Mantenedores costumam responder em até 7 dias
Todas as issues de python-rope/rope
Issues semelhantes
-
needs-area-label
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 66/100
Mantenedores costumam responder em até 2 dias
-
enhancement good first issue
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 84/100
Official-Space-AI/OpenPhysGraspGen#114 ·
Mantenedores costumam responder em até 2 dias
-
changelog investigate
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 62/100
ramnes/notion-sdk-py#441 ·
-
qa_bug
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100
NVIDIA-NeMo/Gym#5644 ·
Mantenedores costumam responder em até 2 dias
-
BUG: catalog database credentials printed to logs at startupTalvez já em andamento @cjboyle assumiu hoje. Aberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 70/100
Mantenedores costumam responder em até 1 dia