Open HedgehogCode opened 9 months ago
@tkrabel-db @HedgehogCode any way we can get this merged? looking forward to this change
@PeterCardenas I'm afraid I have no rights to do so. @ccordoba12 can you TAL?
Thanks for your work on this! I am really looking forward for this to get merged.
I think there is still some room for improvement here, though. For variables with None
in their union type or Optional
type, the variable gets simply shown as NoneType
. jedi-language-server is slightly better with showing the complete definition line in that regard.
Here is what python-lsp-server with this PR shows (without this PR python-lsp-server shows nothing at all in this situation):
And here is what jedi-language-server shows:
The real solution would be to correctly show a union type here. Since both lsps don't do that I assume this is an issue with jedi, I haven't check though.
Sorry for the late reply.
The example above showed NoneType()
because jedi returns a signature for this definition. However, signatures are only interesting for "function" and "class" (BaseName#get_signatures). I changed the code to only show signatures for "function" and "class".
The new code shows Union[NoneType, int]
on hover (this was already implemented - we just did not get there because of the signature).
I also changed the code to show the type in cases where we have a signature but this is not the only option. Example:
def b():
return 1
if input() == "yes":
b = 10
b
On hover over "b":
b()
Union[b, int]
This PR solves #444.
I tried to describe the changes pretty well in the comments in the code. Note that there are two
TODO(Review)
comments that I would like feedback on.Here are some examples of how the hover results change with this code change. The new results are highlighted with a green border.