mirror of
https://github.com/astral-sh/ruff.git
synced 2025-09-21 01:29:56 +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
|
@ -19,6 +19,7 @@ use ruff_text_size::TextSize;
|
|||
use crate::cell::CellOffsets;
|
||||
use crate::index::NotebookIndex;
|
||||
use crate::schema::{Cell, RawNotebook, SortAlphabetically, SourceValue};
|
||||
use crate::RawNotebookMetadata;
|
||||
|
||||
/// Run round-trip source code generation on a given Jupyter notebook file path.
|
||||
pub fn round_trip(path: &Path) -> anyhow::Result<String> {
|
||||
|
@ -383,6 +384,10 @@ impl Notebook {
|
|||
&self.raw.cells
|
||||
}
|
||||
|
||||
pub fn metadata(&self) -> &RawNotebookMetadata {
|
||||
&self.raw.metadata
|
||||
}
|
||||
|
||||
/// Return `true` if the notebook is a Python notebook, `false` otherwise.
|
||||
pub fn is_python_notebook(&self) -> bool {
|
||||
self.raw
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue