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

No docstrings in signature help when function is stubbed #784

Closed
sebastianzolg opened this issue Dec 28, 2020 · 23 comments
Closed

No docstrings in signature help when function is stubbed #784

sebastianzolg opened this issue Dec 28, 2020 · 23 comments
Labels
docstrings needs investigation Could be an issue - needs investigation

Comments

@sebastianzolg
Copy link

After switching over to Pylance (as suggested by the VS Code pop-up), I immediately discovered a big discrepancy between docstring support/formatting of Jedi and Pylance.
I've read several issues spread over various repos to find out the current state of docstring support. Honestly, I lost track.
Is it just me, or is this a little bit confusing?

From reading past issues, I came up with a few questions:

1) Why are there no additional docstrings for the most basic methods like print()

image

2) What kind of formatting can I expect from docstrings displayed by Pylance?
I saw long and unreadable examples without any line break.

3) What is the discussion of "docstring only work for 3rd party libraries and not builtins" all about?

4) Why do we need stubs for libraries like Pandas to show docstrings?
I know that from reading other issues.

What can I expect from docstring support in the latest version?

My Setup:
OS: Windows 10
Python: 3.9.1
Python exts.: v2020.12.424452561
Pylance exts.: v2020.12.2

@judej
Copy link
Contributor

judej commented Dec 28, 2020

@sebastianzolg, thanks for the questions. Responding to them:

  1. The docstrings for built-ins are scraped from the built-in modules. So, what we show is what we are able to retrieve from there.
  2. We are working on formatting and they will show up as enhancements in the future. There are a couple of issues open on this for one: Indented regions in docstrings are highlighted as code #83
  3. There should be docstrings - as you have seen with print()
  4. We extract the docstrings from type stubs or from source. So, in the case of Pandas for example, since the modules are compiled, we look for docstrings in the stub files.

Support for docstrings will improve as we support more formats and as type stubs get more docstrings.

Hope you are enjoying Pylance and please let me know if there are any other questions I can answer

@judej judej added the waiting for user response Requires more information from user label Dec 28, 2020
@github-actions github-actions bot removed the triage label Dec 28, 2020
@sebastianzolg
Copy link
Author

Thank you very much, @judej, for your detailed answer. Very much appreciated!
It all makes sense to me, but I have one question left, and it might be the root cause of my confusion:

Why are the Jedi results in Jupyter Lab so much better than Pylance in VSCode?

Jupyter Lab (Jedi)
image

VS Code (Pylance)
image

@jakebailey
Copy link
Member

jakebailey commented Jan 4, 2021

I believe that's the signature help tooltip; I think it "looks worse" because we aren't including the function docstring in that view. You'd see the same thing if you hit Ctrl+Shift+Space within the () of the call in a regular file.

@jakebailey jakebailey added needs investigation Could be an issue - needs investigation and removed waiting for user response Requires more information from user labels Jan 4, 2021
@sebastianzolg
Copy link
Author

Thanks for your answer, @jakebailey !
Are docstrings different from signature help tooltips? You see, I'm confused about what the expected behavior should be.
In simple words: Is the goal of Pylance to match Jupyter Lab and Jedi's look and feel, or are you planning to go a different direction? Of course, I'd love to see an ETA on the improvements.

Again, thank you very much for taking the time to explain this to me.

@jakebailey
Copy link
Member

"docstring" is just the text out of the python code triple quoted string; tooltip is the entire tooltip which can include information from the analysis as well as a docstring.

If you hover over print, you should see more info, but IIRC the tooltips as a whole in the new notebook system are not all there.

@konstantin-schekotihin
Copy link

konstantin-schekotihin commented Jan 29, 2021

If you hover over print, you should see more info, but IIRC the tooltips as a whole in the new notebook system are not all there.

@jakebailey If I hover over figure in shows "Loading..." forever

image

@jakebailey
Copy link
Member

@konstantin-schekotihin Just to confirm, is the above while in a juypter notebook, or in a regular file?

@konstantin-schekotihin
Copy link

@jakebailey In a Jupyter notebook. The mouse is over plt.figure()

@jakebailey
Copy link
Member

Your issue is likely microsoft/vscode-jupyter#4218, then, which will be fixed in their next release.

@jakebailey jakebailey changed the title What's the state of docstring support in Pylance? No docstrings in signature help Feb 2, 2021
@jakebailey
Copy link
Member

Retitling this to match the original report, which was not having docstrings in the signature help.

@jakebailey
Copy link
Member

The issue here is that we haven't piped the source mapper through the signature help, which means we don't pull docstrings from real source if a stub is available. Hover and completion have done this, but signature help is missing it and is pulling info only from the immediately available AST nodes.

@jakebailey jakebailey changed the title No docstrings in signature help No docstrings in signature help when function is stubbed Mar 12, 2021
@inetfuture

This comment has been minimized.

@jakebailey

This comment has been minimized.

@jakebailey
Copy link
Member

This was actually fixed in 2021.3.3, but we didn't close this issue.

image

@Jakob-Bjorner-CapsicoHealth

The original problem persists. There is still no docstring in the jupyter notebook for any functions, only the method header in the suggestions given from pylance.

@jakebailey
Copy link
Member

Please file a new issue with an example and screenshot of what you're describing. I'm not sure your issue is related to this one.

@Jakob-Bjorner-CapsicoHealth
Copy link

Jakob-Bjorner-CapsicoHealth commented Jun 26, 2021

Please file a new issue with an example and screenshot of what you're describing. I'm not sure your issue is related to this one.

I am getting the same thing as in the first image presented.
image
where as I would like to see the docstring inside this popup which is available in standard .py files through pylance.

Right now, I have found that using the insider edition of vs code in the new jupyter notebook ui resolves this problem of no added docstring, but this was very frustrating to get to work.

@jakebailey
Copy link
Member

That looks like the old Jupyter notebook UI, which I don't believe supports docstrings on signature help.

@Jakob-Bjorner-CapsicoHealth

That looks like the old Jupyter notebook UI, which I don't believe supports docstrings on signature help.

is there a way to convert to the new UI in the non-insider edition of vs code. And why would the old UI be made the default for opening ipynb files if it isn't fully up to date? This was a new install of vs code that I tried it on.

@jakebailey
Copy link
Member

It's not the default because it's a work in progress. VS Code is still working on native notebook support; the old Jupyter UI was made from scratch.

I think you can do:

    "jupyter.experiments.optInto": [
        "__NativeNotebookEditor__"
    ],

Which will force you into the newer UI.

@tdomhan
Copy link

tdomhan commented Nov 6, 2021

I have the same issue. While jedi can show both the docstring and the type annotation pylance just shows the latter.

jedi:
Screenshot 2021-11-06 at 08 03 27
pylance:
Screenshot 2021-11-06 at 08 02 40

@deem-lab
Copy link

deem-lab commented Jul 7, 2022

I have the same issue nearly a year later. If I need to edit my .json settings, can you direct me to some basic instructions on how to do so?

@erictraut
Copy link
Contributor

@deem-lab, this issue has been closed for the better part of a year. If you think that you are experiencing a bug with pylance, please open a new issue with details about what you're seeing. If you have questions about how to use pylance, feel free to post a question in the discussions tab.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docstrings needs investigation Could be an issue - needs investigation
Projects
None yet
Development

No branches or pull requests

10 participants