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

Autocomplete: Expose Jedi signature to frontends #249

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

lgeiger
Copy link

@lgeiger lgeiger commented Jun 6, 2017

This adds support for function signatures introduced in ipython/ipython#10507 so we can try them in other frontends.

/cc @Carreau

comps = []
for comp in completions:
comps.append(dict(
start=comp.start,
end=comp.end,
text=comp.text,
type=comp.type,
signature=getattr(comp, 'signature', '')
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Depending on the IPython version, completions may or may not return the function signature. Therefor I used getattr to make sure we stay compatible.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1, one thing I was thinking about is to give that a name more generic name (right_extra?) to see how that would extend to other languages. I can't really think of any language where signature is on the left, or maybe language that have operators would want to send extra text to display on the left and right ? and call that extra_left and extra_right ?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good Point! signature probably only makes sense in case of functions.
Atom's autocomplete-plus uses the terms rightLabel and leftLabel so right_label would be another option.

Copy link
Member

@minrk minrk Jun 8, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm always happy to copy something that already exists, so +1 to right_label

@ivanov
Copy link
Member

ivanov commented May 15, 2021

Hey there @lgeiger. I'm going through old issues and it seems this one stalled.

I've just rebased and changed the generic 'signature' to a 'right_label' as per discussion above.

Do you still have cycles to push forward on this? Either way is fine, I think we just need to document the change before merging, so others can know they can start using this. So that would be the next step (unless, of course, I've missed something entirely and this has been superseded by another avenue of transmitting signatures).

@ivanov
Copy link
Member

ivanov commented May 17, 2021

Python 3.9 test failed here, but in a weird timeout - so I'm just gonna try running it again.

@krassowski
Copy link
Member

krassowski commented Sep 4, 2021

Note: LSP uses just label which includes both the name of the function and the arguments. I think that returning text + signature and calling it label is a more future-proof approach as compared to using right_label.

While LSP does use signature in other contexts, this is definitely a completion label; also thinking about other uses of completer which modify the already entered text which is already possible with IPython - e.g. the LaTeX symbols completions, pre-pending text on the left would not be unexpected for me. Think about a user trying to complete sqrt but they have not imported it but they have math available - in that case the label could be math.sqrt(x) (and the text would be math.sqrt with adjusted start/end coordinates). How does that sound?

Edit: Also, JupyterLab is ready to receive label (well, we will need to actually pass it, but the current interface does separate label from insertText so we can easily adopt the label from this PR).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants