-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
ruff server
: Closing an untitled, unsaved notebook document no longer throws an error
#11942
Conversation
|
code | total | + violation | - violation | + fix | - fix |
---|---|---|---|---|---|
NPY201 | 1 | 1 | 0 | 0 | 0 |
Linter (preview)
ℹ️ ecosystem check detected linter changes. (+1 -0 violations, +0 -0 fixes in 1 projects; 49 projects unchanged)
PlasmaPy/PlasmaPy (+1 -0 violations, +0 -0 fixes)
ruff check --no-cache --exit-zero --ignore RUF9 --output-format concise --preview
+ src/plasmapy/diagnostics/langmuir.py:1396:23: NPY201 `np.trapz` will be removed in NumPy 2.0. Use `numpy.trapezoid` on NumPy 2.0, or ignore this warning on earlier versions.
Changes by rule (1 rules affected)
code | total | + violation | - violation | + fix | - fix |
---|---|---|---|---|---|
NPY201 | 1 | 1 | 0 | 0 | 0 |
I've confirmed that this also fixes #11851 😄 |
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.
Unfortunately, the LSP specification isn't explicit about whether the document-specific did*
notifications are sent for notebook documents. It might be worth opening an issue on the LSP spec repository to ask for clarification.
This is the sort of change where I would love to have the ability to write E2E tests, ideally with a way to debug if the document was indeed closed (e.g. by using the debug command?)
Would you mind updating your test plan with a verification that the document actually was removed and that we aren't just leaking memory now (e.g. by running the debug command after closing all documents and checking that the open document count is now down to zero (including cells)
@MichaReiser As it turns out, there was a bug in this PR that would leave notebook documents remaining in the index. I've re-done this PR in a way that avoids assumptions about call order and makes snapshot failures non-failing. |
@snowsignal I'm okay with the change itself but I get the impression that we don't fully understand the lifecycle events of notebook documents (at least I don't!) I think it would be very valuable to document what the lifecycle events for notebooks are. Why do we need to deregister them in both places? Isn't just one enough. I'm okay merging this PR as a fix but we should follow up by either figuring the behavior out ourselves or creating an issue on the LSP project to ask for clarification (or study e.g. the VS Code source code) |
CodSpeed Performance ReportMerging #11942 will improve performances by 5.07%Comparing Summary
Benchmarks breakdown
|
@MichaReiser After considering this further, I removed the redundant de-registration loop from How would you want me to go about documenting the notebook cell lifecycle? I've documented how notebook cells are removed via ruff/crates/ruff_server/src/session/index.rs Lines 340 to 344 in 3d0230f
What do you think is missing? I'll add that documentation in a follow-up PR. |
This is helpful. Thanks for pointing it out. What's unclear to me is why closing a document in |
Summary
Fixes #11651.
Fixes #11851.
We were double-closing a notebook document from the index, once in
textDocument/didClose
and then in thenotebookDocument/didClose
handler. The second time this happens, taking a snapshot fails.I've rewritten how we handle snapshots for closing notebooks / notebook cells so that any failure is simply logged instead of propagating upwards. This implementation works consistently even if we don't receive
textDocument/didClose
notifications for each specific cell, since they get closed (and the diagnostics get cleared) in the notebook document removal process.Test Plan
Create: New Jupyter Notebook
command from the VS Code command palette (Ctrl/Cmd + Shift + P
)Ruff: print debug information
) to confirm that there are no open documents