diff --git a/src/lib.rs b/src/lib.rs index 739bf9a7c5..f893ef564b 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -47,7 +47,7 @@ pub mod settings; pub mod visibility; /// Run ruff over Python source code directly. -pub fn check(path: &Path, contents: &str, quiet: bool) -> Result> { +pub fn check(path: &Path, contents: &str) -> Result> { // Find the project root and pyproject.toml. let project_root = pyproject::find_project_root(&[path.to_path_buf()]); match &project_root { @@ -60,11 +60,8 @@ pub fn check(path: &Path, contents: &str, quiet: bool) -> Result> { None => debug!("Unable to find pyproject.toml; using default settings..."), }; - let settings = Settings::from_configuration(Configuration::from_pyproject( - &pyproject, - &project_root, - quiet, - )?); + let settings = + Settings::from_configuration(Configuration::from_pyproject(&pyproject, &project_root)?); // Tokenize once. let tokens: Vec = tokenize(contents); diff --git a/src/main.rs b/src/main.rs index 019ca1f28a..1edf0d5636 100644 --- a/src/main.rs +++ b/src/main.rs @@ -261,7 +261,7 @@ fn inner_main() -> Result { .map(|pair| PerFileIgnore::new(pair, &project_root)) .collect(); - let mut configuration = Configuration::from_pyproject(&pyproject, &project_root, cli.quiet)?; + let mut configuration = Configuration::from_pyproject(&pyproject, &project_root)?; if !exclude.is_empty() { configuration.exclude = exclude; } diff --git a/src/settings/configuration.rs b/src/settings/configuration.rs index 15806842ab..273fa86867 100644 --- a/src/settings/configuration.rs +++ b/src/settings/configuration.rs @@ -60,9 +60,8 @@ impl Configuration { pub fn from_pyproject( pyproject: &Option, project_root: &Option, - quiet: bool, ) -> Result { - let options = load_options(pyproject, quiet)?; + let options = load_options(pyproject)?; Ok(Configuration { dummy_variable_rgx: match options.dummy_variable_rgx { Some(pattern) => Regex::new(&pattern) diff --git a/src/settings/pyproject.rs b/src/settings/pyproject.rs index 108bf22d0f..9ad68bd3c1 100644 --- a/src/settings/pyproject.rs +++ b/src/settings/pyproject.rs @@ -4,6 +4,7 @@ use std::path::{Path, PathBuf}; use anyhow::Result; use common_path::common_path_all; +use log::debug; use path_absolutize::Absolutize; use serde::Deserialize; @@ -69,17 +70,15 @@ pub fn find_project_root(sources: &[PathBuf]) -> Option { None } -pub fn load_options(pyproject: &Option, quiet: bool) -> Result { +pub fn load_options(pyproject: &Option) -> Result { match pyproject { Some(pyproject) => Ok(parse_pyproject_toml(pyproject)? .tool .and_then(|tool| tool.ruff) .unwrap_or_default()), None => { - if !quiet { - eprintln!("No pyproject.toml found."); - eprintln!("Falling back to default configuration..."); - } + debug!("No pyproject.toml found."); + debug!("Falling back to default configuration..."); Ok(Default::default()) } }