Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Go to does not work with __getattr__ #1946

Open
Morikko opened this issue Jul 12, 2023 · 0 comments
Open

Go to does not work with __getattr__ #1946

Morikko opened this issue Jul 12, 2023 · 0 comments

Comments

@Morikko
Copy link

Morikko commented Jul 12, 2023

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.

@Morikko Morikko changed the title Go to does not work with __getattr__ #21609 Go to does not work with __getattr__ Sep 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants