ruff: Break in compatibility with jupyterlab-lsp + python-lsp-ruff since 0.0.285
I’m not 100% sure this is the right project to raise this, since the problem comes from interaction with python-lsp-ruff
and juptyerlab-lsp
. I only raised it here since the issue arose from a change in ruff.
Since 0.0.285, the jupyterlab-lsp plugin now gives the following diagnostic message:
SyntaxError: Expected a Jupyter Notebook (.ipynb), which must be internally stored as JSON, but found a Python source file: expected value at line 1 column 1
I believe this is because jupyterlab-lsp extracts the python code from the notebook cells, then python-lsp-ruff passes it to ruff via stdin, and specifies --stdin-filename
. Since #6628, this makes ruff expect ipynb JSON, rather than python code, which causes the error.
About this issue
- Original URL
- State: closed
- Created 10 months ago
- Comments: 24 (22 by maintainers)
This is resolved when using
v2.0.0
ofpython-lsp-ruff
, big thanks to @felix-cw for driving this change forward 🥳https://github.com/python-lsp/python-lsp-ruff/releases/tag/v2.0.0
Thanks for merging my pull request!
I think we need to add
--extension ipynb:python
to the call to ruff thatpython-lsp-ruff
makes. I’m not sure about the side effects of this, when it is used outside ofjupyterlab-lsp
though, so it might need to be behind a config option. I’ll reach out to the projects.I think you do not need to worry about how jupyterlab-lsp handles mapping between cells and text content, I am sure this will work well. And yes there is a branch with code actions support but I cannot test it against ruff yet because it just rejects text content on the basis of extension 😉