mirror of
https://github.com/astral-sh/ruff.git
synced 2025-10-02 06:42:02 +00:00
[red-knot] Add notebook support (#12338)
This commit is contained in:
parent
fe04f2b09d
commit
0c72577b5d
12 changed files with 246 additions and 53 deletions
|
@ -3,6 +3,7 @@ use std::fmt::Debug;
|
|||
pub use memory_fs::MemoryFileSystem;
|
||||
#[cfg(feature = "os")]
|
||||
pub use os::OsSystem;
|
||||
use ruff_notebook::{Notebook, NotebookError};
|
||||
pub use test::{DbWithTestSystem, TestSystem};
|
||||
use walk_directory::WalkDirectoryBuilder;
|
||||
|
||||
|
@ -40,6 +41,13 @@ pub trait System: Debug {
|
|||
/// Reads the content of the file at `path` into a [`String`].
|
||||
fn read_to_string(&self, path: &SystemPath) -> Result<String>;
|
||||
|
||||
/// Reads the content of the file at `path` as a Notebook.
|
||||
///
|
||||
/// This method optimizes for the case where the system holds a structured representation of a [`Notebook`],
|
||||
/// allowing to skip the notebook deserialization. Systems that don't use a structured
|
||||
/// representation fall-back to deserializing the notebook from a string.
|
||||
fn read_to_notebook(&self, path: &SystemPath) -> std::result::Result<Notebook, NotebookError>;
|
||||
|
||||
/// Returns `true` if `path` exists.
|
||||
fn path_exists(&self, path: &SystemPath) -> bool {
|
||||
self.path_metadata(path).is_ok()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue