-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Use jupyter inspect to get signature of dynamic functions in notebook editor when language server doesn't provide enough hint. #13259
Conversation
Codecov Report
@@ Coverage Diff @@
## master #13259 +/- ##
==========================================
+ Coverage 59.56% 59.66% +0.09%
==========================================
Files 669 670 +1
Lines 36787 37276 +489
Branches 5181 5286 +105
==========================================
+ Hits 21914 22240 +326
- Misses 13778 13905 +127
- Partials 1095 1131 +36
Continue to review full report at Codecov.
|
@thy09 thanks for submitting this PR. FYI - I have re-opened the issue so we can discuss this. |
@thy09 I just wanted to make it clear, this solution is temporary. Once we move to use the VS Code notebook API, this will no longer work as the intellisenseProvider you modified won't be used anymore. |
let signatures: SignatureInformation[] = []; | ||
if (callable) { | ||
// tslint:disable-next-line:no-object-literal-type-assertion | ||
const signatureInfo = <SignatureInformation>{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not const signatureInfo: SignatureInformation = ...
? (Or just in the below assignment as a literal)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just learn from this line before: https://github.com/microsoft/vscode-python/blob/master/src/client/providers/signatureProvider.ts#L88
Updated according to your suggestion, thanks a lot.
const lsHover = lsResult ? convertToMonacoHover(lsResult) : undefined; | ||
// If lsHover is not valid or it is not a callable with hints, | ||
// we prefer to use jupyterHover which provides better callable hints from jupyter kernel. | ||
const preferJupyterHover = !lsHover || !this.isCallableWithGoodHint(lsHover.contents[0].value); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How does this affect tooltips for things that aren't functions, like variables or modules?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point!
In fact only callables like functions and methods will get the correct jupyter hover,
so normal variables and modules will still prefer to use language server result.
To make the logic more clear, I updated the logic here,
we prefer jupyter only when the language server doesn't provide callable hover
while jupyter provides callable hover.
Thanks for your suggestion!
4f04079
to
cff8239
Compare
…Provider.ts to use notebook.inspect for Hover message and SignatureHelp when PyLance doesn't provide good result.
cff8239
to
a035c36
Compare
Kudos, SonarCloud Quality Gate passed! 0 Bugs No Coverage information |
Thanks for your reminder! When will we move to use the notebook API? This is an important feature for our team, just want to make sure how long could we use this feature. |
This is actively happening now. In the next few months we plan on deprecating the old way of opening notebooks.
Not the way you have it now. It would be possible to reimplement this but requires multiple teams to figure out how (see the e-mail stream about pylance). In fact it may turn out completely different. I think it might help to log a feature request on pylance for this work. (https://github.com/microsoft/pylance-release/issues)
Hopefully we can get something like this to work in the new notebook api. |
Thanks for you kind reply! |
For #13067, we try to get the signature help from Jupyter kernel for a function which is dynamically created in Jupyter notebook, by calling
activeNotebook.inspect
like whatprovideJupyterCompletionItems
does.In the code, when handling the hover request/signature help request, if the following conditions are satisfied, we will show the inspect result from Jupyter Kernel:
Result:
In most cases, the hover and the signature help work as before.
For the case the the function is dynamically created like the following:
Before:
Signature help:
Hover:
After:
Signature help:
Hover:
Has sufficient logging.Has telemetry for enhancements.Unit tests & system/integration tests are added/updated.Test plan is updated as appropriate.package-lock.json
has been regenerated by runningnpm install
(if dependencies have changed).The wiki is updated with any design decisions/details.