microsoft / pylance-release

Documentation and issues for Pylance
Creative Commons Attribution 4.0 International
1.72k stars 768 forks source link

Pylance doesn't show docstring for pandas #4881

Open ydmykr opened 1 year ago

ydmykr commented 1 year ago

The code for reproducing the problem is also very simple, just

import pandas.

I ensure that I've chosen the correct python interpreter and I can run it successfully. However pylance doesn't show docstring for pandas. It just shows (module)panda.

Related on StackOverfolw.

heejaechang commented 1 year ago

@gramster is pandas doc generator supposed to inject module doc string as well?

heejaechang commented 1 year ago

another way to fix it would be improving our doc string logic to get doc string from __doc__ if used on top of """ at the top for module level doc string.

gmarinello commented 1 year ago

I have a similar issue. pandas doesn't show the docstring, but numpy and scipy do. Also the docstring for read_csv is not showing, but for read_excel is fine. Could be an issue with pylance stubs?

gramster commented 1 year ago

The problem with pandas is that many docstrings are computed dynamically at runtime, and don't actually exist in usable form in either the pandas source code or the pandas stubs. We try to work around this by using a utility program to import pandas and introspect the docstrings and then inject some of these into a copy of the pandas stubs that we then bundle. However, we haven't done this systematically; usually just when someone complains about something being missing. It's fairly easy to add new ones as it is controlled by a configuration file with lines containing filenames, class names, and method names. It might be worth moving that file back to https://github.com/microsoft/python-type-stubs where it used to live back when we used to ship our own pandas stubs, so we can take pull requests.

@heejaechang no we don't do the module docstring.