jupyter-lsp / jupyterlab-lsp

Coding assistance for JupyterLab (code navigation + hover suggestions + linters + autocompletion + rename) using Language Server Protocol
https://jupyterlab-lsp.readthedocs.io
BSD 3-Clause "New" or "Revised" License
1.79k stars 145 forks source link

lsp diagnostics not recongnize the `%pylab` magic function #680

Open gaowutong opened 2 years ago

gaowutong commented 2 years ago

The ipython magic function %pylab inline automatically imports matplotlib. However, the lsp diagnostics reports the error "undefined name" when I try to use matplotlib. A similar result happens when using numpy. It only works well when the module is explicitly imported.

krassowski commented 2 years ago

Personally I would not use %pylab inline as it pollutes the global namespace (see https://stackoverflow.com/a/24338062/6646912 for explanation), but we are not an authority on good code, so indeed we could make an exception and include the additional imports. PRs welcome.

Reference: https://ipython.readthedocs.io/en/stable/interactive/magics.html?highlight=pylab#magic-pylab