@@ -17,7 +17,7 @@ use ruff_source_file::{NewlineWithTrailingNewline, UniversalNewlineIterator};
17
17
use ruff_text_size:: { TextRange , TextSize } ;
18
18
19
19
use crate :: autofix:: source_map:: { SourceMap , SourceMarker } ;
20
- use crate :: jupyter:: index:: JupyterIndex ;
20
+ use crate :: jupyter:: index:: NotebookIndex ;
21
21
use crate :: jupyter:: schema:: { Cell , RawNotebook , SortAlphabetically , SourceValue } ;
22
22
use crate :: rules:: pycodestyle:: rules:: SyntaxError ;
23
23
use crate :: IOError ;
@@ -82,8 +82,8 @@ impl Cell {
82
82
Cell :: Code ( cell) => & cell. source ,
83
83
_ => return false ,
84
84
} ;
85
- // Ignore cells containing cell magic. This is different from line magic
86
- // which is allowed and ignored by the parser .
85
+ // Ignore cells containing cell magic as they act on the entire cell
86
+ // as compared to line magic which acts on a single line .
87
87
!match source {
88
88
SourceValue :: String ( string) => string
89
89
. lines ( )
@@ -106,7 +106,7 @@ pub struct Notebook {
106
106
source_code : String ,
107
107
/// The index of the notebook. This is used to map between the concatenated
108
108
/// source code and the original notebook.
109
- index : OnceCell < JupyterIndex > ,
109
+ index : OnceCell < NotebookIndex > ,
110
110
/// The raw notebook i.e., the deserialized version of JSON string.
111
111
raw : RawNotebook ,
112
112
/// The offsets of each cell in the concatenated source code. This includes
@@ -368,7 +368,7 @@ impl Notebook {
368
368
///
369
369
/// The index building is expensive as it needs to go through the content of
370
370
/// every valid code cell.
371
- fn build_index ( & self ) -> JupyterIndex {
371
+ fn build_index ( & self ) -> NotebookIndex {
372
372
let mut row_to_cell = vec ! [ 0 ] ;
373
373
let mut row_to_row_in_cell = vec ! [ 0 ] ;
374
374
@@ -395,7 +395,7 @@ impl Notebook {
395
395
row_to_row_in_cell. extend ( 1 ..=line_count) ;
396
396
}
397
397
398
- JupyterIndex {
398
+ NotebookIndex {
399
399
row_to_cell,
400
400
row_to_row_in_cell,
401
401
}
@@ -413,7 +413,7 @@ impl Notebook {
413
413
/// The index is built only once when required. This is only used to
414
414
/// report diagnostics, so by that time all of the autofixes must have
415
415
/// been applied if `--fix` was passed.
416
- pub ( crate ) fn index ( & self ) -> & JupyterIndex {
416
+ pub ( crate ) fn index ( & self ) -> & NotebookIndex {
417
417
self . index . get_or_init ( || self . build_index ( ) )
418
418
}
419
419
@@ -473,7 +473,7 @@ mod tests {
473
473
use anyhow:: Result ;
474
474
use test_case:: test_case;
475
475
476
- use crate :: jupyter:: index:: JupyterIndex ;
476
+ use crate :: jupyter:: index:: NotebookIndex ;
477
477
use crate :: jupyter:: schema:: Cell ;
478
478
use crate :: jupyter:: Notebook ;
479
479
use crate :: registry:: Rule ;
@@ -561,7 +561,7 @@ print("after empty cells")
561
561
) ;
562
562
assert_eq ! (
563
563
notebook. index( ) ,
564
- & JupyterIndex {
564
+ & NotebookIndex {
565
565
row_to_cell: vec![ 0 , 1 , 1 , 1 , 1 , 1 , 1 , 3 , 3 , 3 , 3 , 3 , 5 , 7 , 7 , 8 ] ,
566
566
row_to_row_in_cell: vec![ 0 , 1 , 2 , 3 , 4 , 5 , 6 , 1 , 2 , 3 , 4 , 5 , 1 , 1 , 2 , 1 ] ,
567
567
}
@@ -666,13 +666,13 @@ print("after empty cells")
666
666
fn test_no_cell_id ( ) -> Result < ( ) > {
667
667
let path = "no_cell_id.ipynb" . to_string ( ) ;
668
668
let source_notebook = read_jupyter_notebook ( path. as_ref ( ) ) ?;
669
- let source_kind = SourceKind :: Jupyter ( source_notebook) ;
669
+ let source_kind = SourceKind :: IpyNotebook ( source_notebook) ;
670
670
let ( _, transformed) = test_contents (
671
671
& source_kind,
672
672
path. as_ref ( ) ,
673
673
& settings:: Settings :: for_rule ( Rule :: UnusedImport ) ,
674
674
) ;
675
- let linted_notebook = transformed. into_owned ( ) . expect_jupyter ( ) ;
675
+ let linted_notebook = transformed. into_owned ( ) . expect_ipy_notebook ( ) ;
676
676
let mut writer = Vec :: new ( ) ;
677
677
linted_notebook. write_inner ( & mut writer) ?;
678
678
let actual = String :: from_utf8 ( writer) ?;
0 commit comments