mirror of
https://github.com/astral-sh/ruff
synced 2026-01-22 05:51:03 -05:00
Move pyproject.toml logging to debug (#506)
This commit is contained in:
@@ -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<Vec<Message>> {
|
||||
pub fn check(path: &Path, contents: &str) -> Result<Vec<Message>> {
|
||||
// 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<Vec<Message>> {
|
||||
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<LexResult> = tokenize(contents);
|
||||
|
||||
@@ -261,7 +261,7 @@ fn inner_main() -> Result<ExitCode> {
|
||||
.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;
|
||||
}
|
||||
|
||||
@@ -60,9 +60,8 @@ impl Configuration {
|
||||
pub fn from_pyproject(
|
||||
pyproject: &Option<PathBuf>,
|
||||
project_root: &Option<PathBuf>,
|
||||
quiet: bool,
|
||||
) -> Result<Self> {
|
||||
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)
|
||||
|
||||
@@ -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<PathBuf> {
|
||||
None
|
||||
}
|
||||
|
||||
pub fn load_options(pyproject: &Option<PathBuf>, quiet: bool) -> Result<Options> {
|
||||
pub fn load_options(pyproject: &Option<PathBuf>) -> Result<Options> {
|
||||
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())
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user