When using an external file that is executed within a notebook with %run file.py, its imports and definitions are not available to the LSP for code completion or signature suggestions. This means that if common functionality is extracted into a common file and included in the notebook, the LSP's features are not as useful as they could be.
Reproduce
Check that signature suggestions work out of the box in a notebook:
Create file two.py with the following contents:
import pandas as pd
def addtwo(i: int) -> int:
return i + 2
Execute the two.py file and notice that signature suggestions do not work for either the import or the function:
Expected behavior
If code is run inside a notebook, I expect code completion and signature suggestions to work. It is after all available to the notebook server.
Context
Operating System and version: MacOs 12.2
Browser and version: Chrome 100.0.4896.127
JupyterLab version: 3.3.4
Language server and version: 1.5.1 with jupyterlab-lsp 3.10.1
Required: installed server extensions
config dir: /Users/XXX/etc/jupyter
jupyter_lsp enabled
- Validating...
jupyter_lsp 1.5.1 OK
jupyterlab enabled
- Validating...
jupyterlab 3.3.4 OK
jupyterlab_git enabled
- Validating...
jupyterlab_git 0.37.1 OK
nbdime enabled
- Validating...
nbdime 3.1.1 OK
Required: installed lab extensions
JupyterLab v3.3.4
/Users/XXX/share/jupyter/labextensions
jupyterlab_pygments v0.2.2 enabled OK (python, jupyterlab_pygments)
nbdime-jupyterlab v2.1.1 enabled OK
@krassowski/jupyterlab-lsp v3.10.1 enabled OK (python, jupyterlab-lsp)
@jupyterlab/git v0.37.1 enabled OK (python, jupyterlab-git)
Other labextensions (built into JupyterLab)
app dir: /Users/XXX/share/jupyter/lab
@jupyterlab/celltags v3.3.4 enabled OK
This is not just limited to the %run magic. I have configured my kernel to run a Python file automatically on startup and it is also not picked up by the LSP.
Description
When using an external file that is executed within a notebook with
%run file.py
, its imports and definitions are not available to the LSP for code completion or signature suggestions. This means that if common functionality is extracted into a common file and included in the notebook, the LSP's features are not as useful as they could be.Reproduce
two.py
with the following contents:two.py
file and notice that signature suggestions do not work for either the import or the function:Expected behavior
If code is run inside a notebook, I expect code completion and signature suggestions to work. It is after all available to the notebook server.
Context
Required: installed server extensions
Required: installed lab extensions
Troubleshoot Output