Skip to main content

parse_cells_unchecked

Function parse_cells_unchecked 

Source
pub fn parse_cells_unchecked(
    source: &str,
    ranges: impl IntoIterator<Item = TextRange>,
    options: &ParseOptions,
) -> Parsed<ModModule>
Expand description

Parses each range of source as an independent module and concatenates the results into a single Parsed<ModModule> whose nodes keep their offsets into source.

This validates sources such as Jupyter notebooks, where each cell must be syntactically valid on its own while later cells can still reference earlier definitions. The ranges must be ordered and non-overlapping.

Consecutive ranges must be separated by a single-byte \n: each range ends just before the separator and the next range starts just after it, as Ruff’s notebook cells are. A syntax error anchored at a cell’s trailing offset then lands on that separator, the cell’s own last line, so it is attributed to that cell rather than to the following one.