-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Autocompletion of Plotly code not working in Visual Studios #3563
Comments
Happening here too. No code completion for pretty ,much all methods Plots showing fine in the output though. |
Same here... Has anyone found a workaround so far? |
Plotly uses lazy loading which isn't very well handled by type checkers. I have a PR that address this issue (#3425), but the Plotly seem so far have not shown interest in merging it. |
I've just merged #3425 :) |
The next version of Plotly.py (coming out in the next few days) will be much better in this regard, and you'll be able to autocomplete off of situations like |
This issue is regarding autocompletion of Plotly code not working in Visual Studios. This was reported to adam@plot.ly by @yankee on the Plotly Forum.
Just to get it out of the way, here are my list of installed packages in the virtual environment I use for data analysis:
Before capturing any gif images for you to pass on to your team, I wanted to experiment a bit with my IDE settings and extensions to rule out any issues they might be causing. Basically make sure that I have a coherent development environment.
There are 2 extensions I uninstalled so that they wouldn't interfere with the built-in code completion feature:
Tabnine especially was interfering with the code completion, because it uses algorithms that provide code completion suggestions based on code you've already typed. So it artificially makes it seem like code completion is working, when actually it is not.
So in the end, here is the complete list of extensions I have installed:
I suspect that the only extensions in this list which could/should ever have an impact on code completion are
Here are my userspace settings:
Especially on the last line, the language server is a setting I wanted to play with. I think this setting has a strong impact on the way code completion behaves, because I think it is the language server that does the parsing of the pip package stubs and actually displays your code completion suggestions. But I'm not 100% sure on that.
vscode lets you choose from the following list of language servers:
I am going to compare Pylance's behavior with Jedi.
Pylance (the default in vscode) is the one I was using when I complained to you about this code completion issue. Code completion works well for code and classes/modules I've written, default Python libraries, and pip installed Python libraries--except for Plotly.
Here it is completing a list of member methods and attributes for a class I wrote.
If I add a docstring to these functions, it also autocompletes for that:
It auto completes well for some essential pip-installed packages as well, even when you don't use type hinting to help the IDE understand the type:
However, it does not autocomplete for Plotly basically at all, or at least not with the classes I'm trying to use, even when using type hinting:
I'm out of time for now, but will explore Jedi later to see if that language server behaves any better. Who knows, maybe this is a Pylance problem? But I wouldn't think so since it works fine with everything else. Hopefully I've documented this thoroughly enough to be useful to your team.
EDIT: If I had to guess, maybe Pylance language server cannot provide suggestions, because it cannot resolve the type of this fig object? If I hover over the type hint I wrote when I declared and defined
fig
, you can see that it can be one of several types:So
fig
can wind up being of typeAny
, of typeModuleType
, or of typeType[FigureWidget]
. Perhaps Pylance just does not know what to do.The text was updated successfully, but these errors were encountered: