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

Signature has wrong class name when using metaclasses #1950

Open
gpotter2 opened this issue Jul 22, 2023 · 0 comments
Open

Signature has wrong class name when using metaclasses #1950

gpotter2 opened this issue Jul 22, 2023 · 0 comments

Comments

@gpotter2
Copy link

gpotter2 commented Jul 22, 2023

Hi,

When using metaclasses, the signature has the wrong class name. Here's a very easy example:

import jedi

class Dummy_metaclass(type):
    def __new__(cls, name, bases, dct):
        dct["ID"] = 0 # something something
        return type.__new__(cls, name, bases, dct)

class Test(metaclass=Dummy_metaclass):
    def __init__(self, a, b, c):
        pass

interpreter = jedi.Interpreter("Test(", path="input-text", namespaces=[locals(), globals()])
sig = interpreter.get_signatures()[0]
print(sig)
print(sig.name)

outputs:

<Signature: index=0 Dummy_metaclass(a, b, c)>
Dummy_metaclass

It should be

<Signature: index=0 Test(a, b, c)>
Test

The ptpython project uses sig.name as shown above to show its results, so this is likely causing prompt-toolkit/ptpython#542

Infos: jedi version used: f2444b4, Python 3.11.2

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