Skip to content

Commit

Permalink
Fix pre-commit issues
Browse files Browse the repository at this point in the history
  • Loading branch information
evanrittenhouse committed Jun 15, 2023
1 parent 11f9a46 commit 58d31b2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
4 changes: 1 addition & 3 deletions crates/ruff/src/jupyter/notebook.rs
Original file line number Diff line number Diff line change
Expand Up @@ -418,12 +418,10 @@ mod test {
use crate::jupyter::schema::Cell;
use crate::jupyter::Notebook;
use crate::registry::Rule;
use crate::source_kind::CodeExtractor;
use crate::test::{test_notebook_path, test_resource_path};
use crate::{assert_messages, settings};

use crate::source_kind::CodeExtractor;
use crate::test::test_resource_path;

/// Read a Jupyter cell from the `resources/test/fixtures/jupyter/cell` directory.
fn read_jupyter_cell(path: impl AsRef<Path>) -> Result<Cell> {
let path = test_resource_path("fixtures/jupyter/cell").join(path);
Expand Down
10 changes: 5 additions & 5 deletions crates/ruff/src/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ use crate::packaging::detect_package_root;
use crate::registry::AsRule;
use crate::rules::pycodestyle::rules::syntax_error;
use crate::settings::{flags, Settings};
use crate::source_kind::SourceKind;
use crate::source_kind::{CodeExtractor, SourceKind};

#[cfg(not(fuzzing))]
fn read_jupyter_notebook(path: &Path) -> Result<Notebook> {
Notebook::read(path).map_err(|err| {
fn extract_code_from_jupyter_notebook(path: &Path) -> Result<Notebook> {
Notebook::extract_code(path).map_err(|err| {
anyhow::anyhow!(
"Failed to read notebook file `{}`: {:?}",
path.display(),
Expand Down Expand Up @@ -59,10 +59,10 @@ pub(crate) fn test_notebook_path(
settings: &Settings,
) -> Result<(Vec<Message>, SourceKind)> {
let path = test_resource_path("fixtures/jupyter").join(path);
let mut source_kind = SourceKind::Jupyter(read_jupyter_notebook(&path)?);
let mut source_kind = SourceKind::Jupyter(extract_code_from_jupyter_notebook(&path)?);
let messages = test_contents(&mut source_kind, &path, settings);
let expected_notebook =
read_jupyter_notebook(&test_resource_path("fixtures/jupyter").join(expected))?;
extract_code_from_jupyter_notebook(&test_resource_path("fixtures/jupyter").join(expected))?;
if let SourceKind::Jupyter(notebook) = &source_kind {
assert_eq!(notebook.cell_offsets(), expected_notebook.cell_offsets());
assert_eq!(notebook.index(), expected_notebook.index());
Expand Down

0 comments on commit 58d31b2

Please sign in to comment.