pylance-release
pylance-release copied to clipboard
Intellisense is messed up. Function information and type checking is useless for matplotlib (and other modules like numpy)
Environment data
- Language Server version: v2021.1.1
- OS and version: WSL2 with Ubuntu
- Python version (& distribution if applicable, e.g. Anaconda): Python 3.8.5 with Anaconda
Problem / Questions
Somehow using Pylance made my Intellisense way worse (compared to Jedi or Microsoft language servers):
Before switching to Pylance I got useful information about functions, classes, etc. (default values for parameters and the docstring)
Now I only get cryptic information and no docstrings.
Type checking worked sometimes and I could actually see which methods are in a class. (see Axes) Now I get no list of the methods, because in most stub files no information is given. Only ...
I could Ctrl+Click on a function,module,class,... and got redirected to the source code. (very helpful) Now I only get redirected to these stub files with no useful information in it.
Is it possible to use Pylance but use only the source code of modules? It seems to me that those stub files are far from being complete and are the cause of those problems. (I wonder why stub files are nessecary if a good docstring is provided and typing information is implemented) I like some Pylance features like the syntax highlighting, but Pylance really messes with my intellisense.
Edit: I've tried figuring more out about this issue by reading somewhat related issues, but I still don't understand why this happens and what I can do to have a better experience using pylance. I can't figure out what stubs are and why they are being used as default if they are totally incomplete. Why aren't stubs being used complementary to the source code? I guess they are useful to give additional type hinting information, but then the rest of the information is lost or has to be added manually? Why is Jedi and Pythlon Language Server getting it right but pylance isn't? I think an entry in the documentation that talks about stubs, the differences to jedi and pls might be helpful. I primarily use the autocomplete and viewing definitions feature of the Python extension and for this Pylance seems not fitted at the moment. I can't understand why Pylance is recommended in VSCode if it's worse than Jedi and pls in this regards.
Before and after comparisons of a few examples
Before: Clean definition with default values presented and the documentation string being shown. After: less readable definition without default values and not documentation string.
Even for numpy the information displayed before was much more readable than afterwards. (And sometimes more complete)
Before: List of methods and variables inside of a class. (instances of these classes are recognized) After: only standard methods of the object class are shown.
Ctrl+Click : Before: redirected to the actual definition in the souce code. After: redirected to incomplete stub files.

You're unfortunately hitting quite a mix of different issues. The stubs we have for matplotlib are a little outdated and need to be updated (I wrote them many months ago), and numpy doesn't yet have type information either (#150). It's also the case that the docstring is missing entirely due to some source mapping issue; matplotlib creates its docstrings at runtime by copying __doc__ from one place to another, a dynamic behavior we can't exactly handle, due to the way pyplot vs axes work (the former wraps the latter). You're also hitting a difference in the way stubs work versus real code, in that default values aren't there (because while the type info for a library may be constant, a different version of the library may change some default).
Is it the case that all of your screenshots that are not Pylance are from jedi? Or is some of this MPLS?
Is it the case that all of your screenshots that are not Pylance are from jedi? Or is some of this MPLS?
To be honest: I'm not sure. I think they all come from MPLS.
For me it was just important to show, that both language servers do a better job at presenting information.
Edit: I think it was Jedi. For MPLS I get formated docstrings and I get complete information less often than with Jedi.
I wonder why you decided to use these stub files.
It's almost impossible to deliver good quality stubs for every popular library.
From one version to the next, the only thing that can be ensured is that the source code reflects the correct information.
Couldn't it be possible to have stub files extend the information given in the source code rather than replace it?
E.g. if there exists a stub file and it holds the information of the return type of a function use this information and get all the other information from the source code. (docstring, default values, ...)
The stubs we have for matplotlib are a little outdated and need to be updated
It's also the case that the docstring is missing entirely due to some source mapping issue; ...
You're also hitting a difference in the way stubs work versus real code, in that default values aren't there
But if I navigate to the source files (via Ctrl+Click), the information is presented to me.
The docstring is there, the default values, all different methods...
So It would be better to extract the information out of the source code instead of using outdated and incomplete stubs.
I still don't know if I'm just using Pylance the wrong way or if it's just not the language server that's good for me at the moment.
I appreciate the work you put into Pylance, but it just seems to not fit my usecase. That is getting information about the functions/methods/classes/modules... I want to use, so I don't have to memorize those or look it up in their documentation.
@NicoJG I can totally relate to this. I switched to vscode insider today and by its recommendation, I installed the pylance. The speed is so much better compared to others, but to me, usage comes first. It goes to stabs instead of the definitions and everything is type None. I switched back to Microsoft. I will definitely give pylance a shot in the future when these are fixed and these issues are critical in my opinion.
@jahaniam Just wanted to share that we have an improvement coming soon for go to definition and go to declaration behaviour planned (see #65) which I think will alleviate some of the pain points you're referring to.
Also of note here is that, similarly to the dynamic docstring case, any native extension module docstrings won't be shown as pylance doesn't import modules to extract information from them, under a false assumption IMHO that the docstring will be available in the type stubs, which they very rarely, or even never, are.
we now go to source by default if we can. (there are cases we can't such as no source files, or source is compiled module) but also provide option to go to stubs if user wants to.
things like
- merging stub and source information for better IDE experience or
- better presentation on completion/hover/signature help tooltip (such as showing default value, better signature presentation, better doc string support and etc) or
- handling of compiled module
will need have discussion since all these will be expensive for perf and implementation.
but, we might be able to support default value in signature like how we do doc string.
We've made some improvements in this area. Closing issue. If you would like to see more done here, please reopen.