You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, I encountered this weird bug where jedi can return incorrect signature for dataclass constructors.
A minimal example to reproduce this:
importjedi, jedi.api.classess=jedi.Script(
"""\from dataclasses import dataclass@dataclassclass Foo: bar: int"""
)
defs=s.goto(3, 8) # go to Foo directlyprint(f"{len(defs)=}")
n=defs[0]
assertisinstance(n, jedi.api.classes.Name)
print(n._get_docstring_signature())
This would return the correct result:
len(defs)=1
Foo(bar: int)
However, if I go to bar first and then call parent()
defs=s.goto(4, 6) # first go to barprint(f"{len(defs)=}")
n=defs[0].parent() # then go to parentassertisinstance(n, jedi.api.classes.Name)
print(n._get_docstring_signature())
jedi returns incorrect result:
len(defs)=1
Foo()
In my application, I need to analyze the definitions used by a given piece of code, and when there are class attribute or method usages, I'm using parent() to also include the class signatures. This bug is causing incorrect class signatures to be returned. Any idea what causes this or how to fix this?
Many Thanks!
The text was updated successfully, but these errors were encountered:
I'm pretty sure that this is not going to be fixed, because parent() has a very low usage and therefore low priority. However feel free to try and fix it. The root cause is probably that at the point you are looking at the dataclass signature, Jedi thinks its just a class and looks at that __init__, which is basically empty.
Hi, I encountered this weird bug where jedi can return incorrect signature for dataclass constructors.
A minimal example to reproduce this:
This would return the correct result:
However, if I go to
bar
first and then callparent()
jedi returns incorrect result:
In my application, I need to analyze the definitions used by a given piece of code, and when there are class attribute or method usages, I'm using
parent()
to also include the class signatures. This bug is causing incorrect class signatures to be returned. Any idea what causes this or how to fix this?Many Thanks!
The text was updated successfully, but these errors were encountered: