-
Notifications
You must be signed in to change notification settings - Fork 194
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add notebooks suppport to pylsp #389
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My first impression is that this is a good initial implementation. There are many things that can be improved (but could be subsequent PRs).
pylsp/python_lsp.py
Outdated
} | ||
|
||
cell_list.append(data) | ||
total_source = total_source + "\n" + cell_document.source |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This and the other JSON file appear unused (in favour of hard-coded expectations).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your contribution @tkrabel-db!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 <[email protected]>
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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No objections from me, looks good for a first step.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @tkrabel-db!
Thanks for the reviews! |
Jargon
What changes are proposed?
Add Notebook Support to LSP for
notebookDocument/didOpen
,*/didChange
,*/didClose
messages (#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/didOpen
andnotebookDocument/didChange
, and that the server keeps the workspace in sync. These helpers could also be used to add stronger testing totextDocument
related features.