jedi
jedi copied to clipboard
Go to does not work with __getattr__
Description
I have a class B
that wraps another one A
through composition. I have setup __getattr__
to transfer everything from B
to A
.
The completion is working but when I want to Go to
on b.toto
, I have no definition found.
The completions were probably added there: #997
Code
import jedi
code = """
class A:
def toto(self, a: int):
...
class B:
_a: A
def __getattr__(self, name):
return getattr(self._a, name)
b = B()
b.toto(a="1")
"""
jedi_script = jedi.Script(code=code)
jedi_script.goto(line=16, column=1, follow_imports=True)
# [<Name full_name='__main__.b', description='b = B()'>]
jedi_script.complete(line=16, column=4)
# [<Completion: toto>]
jedi_script.goto(line=16, column=4, follow_imports=True)
# []
Expected
I would expect that the function goto
returns [<Name full_name='__main__.A.toto', description='def toto'>]
like if I would apply it on a.toto
.
Actual
It returns an empty array.