mirror of
https://github.com/astral-sh/ruff.git
synced 2025-09-30 22:01:47 +00:00
Add CellOffsets
abstraction (#8814)
Refactor `Notebook::cell_offsets` to use an abstract struct for storing the cell offsets. This will allow us to add useful methods on it.
This commit is contained in:
parent
0cb438dd65
commit
727e389cac
6 changed files with 50 additions and 16 deletions
|
@ -9,6 +9,7 @@ use log::error;
|
|||
use rustc_hash::FxHashMap;
|
||||
|
||||
use ruff_diagnostics::Diagnostic;
|
||||
use ruff_notebook::Notebook;
|
||||
use ruff_python_ast::imports::ImportMap;
|
||||
use ruff_python_ast::PySourceType;
|
||||
use ruff_python_codegen::Stylist;
|
||||
|
@ -149,6 +150,7 @@ pub fn check_path(
|
|||
source_type.is_ipynb(),
|
||||
) {
|
||||
Ok(python_ast) => {
|
||||
let cell_offsets = source_kind.as_ipy_notebook().map(Notebook::cell_offsets);
|
||||
if use_ast {
|
||||
diagnostics.extend(check_ast(
|
||||
&python_ast,
|
||||
|
@ -173,8 +175,8 @@ pub fn check_path(
|
|||
stylist,
|
||||
path,
|
||||
package,
|
||||
source_kind,
|
||||
source_type,
|
||||
cell_offsets,
|
||||
);
|
||||
imports = module_imports;
|
||||
diagnostics.extend(import_diagnostics);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue