Add notebooks suppport to pylsp#389
Conversation
Support notebookDocument/didOpen and textDocument/publishDiagnostics on a notebook document
|
@krassowski @ccordoba12 FYI. Let's talk code! :) |
too-many-public-methods, dangerous-default-value, unused-import, too-many-locals, redefined-outer-name
pylsp/python_lsp.py
Outdated
| } | ||
|
|
||
| cell_list.append(data) | ||
| total_source = total_source + "\n" + cell_document.source |
There was a problem hiding this comment.
(this does not need to happen in this PR) different linters will complain about to few or too many.
- Maybe number of lines could be configurable.
- Maybe there should be a way to maks out irrelevant diagnostics on junctions of cells.
There was a problem hiding this comment.
This and the other JSON file appear unused (in favour of hard-coded expectations).
There was a problem hiding this comment.
True. I was adding them so that future readers have quick examples to get a feeling for potential diagnostics. At least examples would have been very helpful for me. However, I have just a 2/5 preference for keeping examples in the repo, so happy to remove them. WDYT?
|
Windows failures appear relevant (is this an async testing issue on older Python versions?). |
From the Test logs, it seems that the test cases timed out because loading the server and plugins took too long. I'll increase the timeout to 30 seconds. Let's check if that helps. |
|
@krassowski can you TAL again? I think I have addressed the important issues. Others will be tracked as follow ups. I also ran |
…iagnostics notification since the first call is a n empty diagnostics for the closed cell
|
@krassowski I fixed a regression to |
Nop, there isn't, sorry.
I think that's controlled by Github. You'll be automatically granted permissions once your first PR is merged into this repo. |
@ccordoba12 if it's ok, I'd add pre-commit hooks in a separate PR. |
ccordoba12
left a comment
There was a problem hiding this comment.
Thanks for your contribution @tkrabel-db!
There was a problem hiding this comment.
This file has similar code to the one already present in test/test_language_server.py, such as CALL_TIMEOUT, start/start_client, _ClientServer/ClientSever, client_server/client_server_pair and test_initialize.
Why is there so much similar code here? Can't you refactor what's already in test/test_language_server.py and use it here too?
There was a problem hiding this comment.
The code is similar but has a substantial difference, namely that in test_notebook_document.py. ClientServer returns also a reference to the server so that we can inspect the server's workspace and e.g. spy on server messages being send as a reaction to client messages. This allows us to fully test client server communication. CALL_TIMEOUT has different values due to the nuances of what we test. I am happy to align that later if I better understand what is exactly happening in test_language_server.py. The tests there are skipped in certain situations and marked as flaky which makes me think that aligigning the two suites will take some deeper thinking and time.
However, I do agree that this should be refactored, and I'd like to do this in a follow up ticket.
WDYT @ccordoba12?
There was a problem hiding this comment.
The tests there are skipped in certain situations and marked as flaky which makes me think that aligigning the two suites will take some deeper thinking and time.
Ok, I see.
However, I do agree that this should be refactored, and I'd like to do this in a follow up ticket.
Ok, I saw that you opened issue #410 about it, so that's fine for me.
Co-authored-by: Carlos Cordoba <ccordoba12@gmail.com>
|
Pinging @krassowski about this one to see if he's ok with it. If I don't hear from him in the next couple of days, I'll merge because it looks good to me now. |
krassowski
left a comment
There was a problem hiding this comment.
No objections from me, looks good for a first step.
|
Thanks for the reviews! |
Jargon
What changes are proposed?
Add Notebook Support to LSP for
notebookDocument/didOpen,*/didChange,*/didClosemessages (#308). Other messages are pending.How is this tested?
I added unit tests and introduced a test helper classes that let us send notification messages to the language server and inspect its state. This helps us assert on messages being sent between LC and LS. More specifically, I tested that the new LS sends correct diagnostics on
notebookDocument/didOpenandnotebookDocument/didChange, and that the server keeps the workspace in sync. These helpers could also be used to add stronger testing totextDocumentrelated features.