mirror of
https://github.com/astral-sh/ruff.git
synced 2025-09-30 22:01:47 +00:00
Add cell indexes to all diagnostics (#9387)
## Summary Ensures that any lint rules that include line locations render them as relative to the cell (and include the cell number) when inside a Jupyter notebook. Closes https://github.com/astral-sh/ruff/issues/6672. ## Test Plan `cargo test`
This commit is contained in:
parent
f0d43dafcf
commit
328262bfac
10 changed files with 141 additions and 25 deletions
|
@ -148,6 +148,7 @@ pub fn check_path(
|
|||
match tokens.into_ast_source(source_kind, source_type) {
|
||||
Ok(python_ast) => {
|
||||
let cell_offsets = source_kind.as_ipy_notebook().map(Notebook::cell_offsets);
|
||||
let notebook_index = source_kind.as_ipy_notebook().map(Notebook::index);
|
||||
if use_ast {
|
||||
diagnostics.extend(check_ast(
|
||||
&python_ast,
|
||||
|
@ -161,6 +162,7 @@ pub fn check_path(
|
|||
package,
|
||||
source_type,
|
||||
cell_offsets,
|
||||
notebook_index,
|
||||
));
|
||||
}
|
||||
if use_imports {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue