diff --git a/src/autofix/fixer.rs b/src/autofix/fixer.rs index a91596c13c..a3cb42cdcd 100644 --- a/src/autofix/fixer.rs +++ b/src/autofix/fixer.rs @@ -6,6 +6,8 @@ use rustpython_parser::ast::Location; use crate::autofix::{Fix, Patch}; use crate::checks::Check; +// TODO(charlie): The model here is awkward because `Apply` is only relevant at +// higher levels in the execution flow. #[derive(Hash)] pub enum Mode { Generate, diff --git a/src/lib.rs b/src/lib.rs index 61a5dee7fa..d561f9939c 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -45,8 +45,8 @@ pub mod settings; pub mod source_code_locator; pub mod visibility; -/// Run ruff over Python source code directly. -pub fn check(path: &Path, contents: &str) -> Result> { +/// Run Ruff over Python source code directly. +pub fn check(path: &Path, contents: &str, autofix: bool) -> Result> { // Find the project root and pyproject.toml. let project_root = pyproject::find_project_root(&[path.to_path_buf()]); match &project_root { @@ -75,7 +75,7 @@ pub fn check(path: &Path, contents: &str) -> Result> { tokens, &noqa_line_for, &settings, - &Mode::None, + &if autofix { Mode::Generate } else { Mode::None }, )?; Ok(checks)