mirror of
https://github.com/astral-sh/ruff.git
synced 2025-09-30 13:51:37 +00:00
Add Jupyter Notebook document change snapshot test (#11944)
## Summary Closes #11914. This PR introduces a snapshot test that replays the LSP requests made during a document formatting request, and confirms that the notebook document is updated in the expected way.
This commit is contained in:
parent
927069c12f
commit
3ab7a8da73
13 changed files with 921 additions and 20 deletions
|
@ -13,7 +13,7 @@ pub(super) type CellId = usize;
|
|||
/// The state of a notebook document in the server. Contains an array of cells whose
|
||||
/// contents are internally represented by [`TextDocument`]s.
|
||||
#[derive(Clone, Debug)]
|
||||
pub(crate) struct NotebookDocument {
|
||||
pub struct NotebookDocument {
|
||||
cells: Vec<NotebookCell>,
|
||||
metadata: ruff_notebook::RawNotebookMetadata,
|
||||
version: DocumentVersion,
|
||||
|
@ -30,7 +30,7 @@ struct NotebookCell {
|
|||
}
|
||||
|
||||
impl NotebookDocument {
|
||||
pub(crate) fn new(
|
||||
pub fn new(
|
||||
version: DocumentVersion,
|
||||
cells: Vec<lsp_types::NotebookCell>,
|
||||
metadata: serde_json::Map<String, serde_json::Value>,
|
||||
|
@ -59,7 +59,7 @@ impl NotebookDocument {
|
|||
|
||||
/// Generates a pseudo-representation of a notebook that lacks per-cell metadata and contextual information
|
||||
/// but should still work with Ruff's linter.
|
||||
pub(crate) fn make_ruff_notebook(&self) -> ruff_notebook::Notebook {
|
||||
pub fn make_ruff_notebook(&self) -> ruff_notebook::Notebook {
|
||||
let cells = self
|
||||
.cells
|
||||
.iter()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue