Open DonJayamanne opened 1 month ago
Pylance having to monitor notebook changes
For what it's worth, we don't do this now. The vscode-languageclient-npm module does. So theoretically any language can listen for notebook events, not just Pylance.
So theoretically any language can listen for notebook events, not just Pylance.
How does Pylance get the Python env associated with a notebook?
How does Pylance get the Python env associated with a notebook?
We ask the python extension for the environment for the current file. This happens after we get the notebook changed event.
We ask the python extension for the environment for the current file.
awesome, then this change will make this workflow work properly
What I'm getting at is Pylance will not need the registerJupyterPythonPathFunction
(private) api anymore and you can use the official Python extension API. this way others language servers can benefit from this, else if some other extension like Ruff or Jedi (if there were other extension) need this, then they would need a new API or a similar hook...
I.e. just use getActiveEnvironmentPath(resource?: Resource): EnvironmentPath
and onDidChangeActiveEnvironmentPath
to detect changes to Python envs associated with Notebooks and the like (still free to use notebook change events as well).
See https://github.com/microsoft/vscode-jupyter/issues/15987
Should also fix https://github.com/microsoft/vscode-jupyter/issues/16112 Should also avoid Pylance having to monitor notebook changes and then trying to figure out the Environment for a Notebook.
@rchiodo @heejaechang @debonte Please can you let me know if this works I.e. going forward (we can plan how we roll this out)
onDidChangeActiveEnvironmentPath
will be triggered with the corresponding UriI believe this should simplify things. @karthiknadig /cc