mirror of
https://github.com/astral-sh/ruff.git
synced 2025-08-03 02:12:22 +00:00
Log configuration in ruff_dev (#6193)
**Summary** This includes two changes: * Allow setting `-v` in `ruff_dev`, using the `ruff_cli` implementation * `debug!` which ruff configuration strategy was used This is a byproduct of debugging #6187. **Test Plan** n/a
This commit is contained in:
parent
9063f4524d
commit
e52b636da0
2 changed files with 16 additions and 1 deletions
|
@ -1,6 +1,7 @@
|
||||||
use std::path::{Path, PathBuf};
|
use std::path::{Path, PathBuf};
|
||||||
|
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
|
use log::debug;
|
||||||
use path_absolutize::path_dedot;
|
use path_absolutize::path_dedot;
|
||||||
|
|
||||||
use ruff::resolver::{
|
use ruff::resolver::{
|
||||||
|
@ -25,6 +26,7 @@ pub fn resolve(
|
||||||
let mut config = Configuration::default();
|
let mut config = Configuration::default();
|
||||||
overrides.process_config(&mut config);
|
overrides.process_config(&mut config);
|
||||||
let settings = AllSettings::from_configuration(config, &path_dedot::CWD)?;
|
let settings = AllSettings::from_configuration(config, &path_dedot::CWD)?;
|
||||||
|
debug!("Isolated mode, not reading any pyproject.toml");
|
||||||
return Ok(PyprojectConfig::new(
|
return Ok(PyprojectConfig::new(
|
||||||
PyprojectDiscoveryStrategy::Fixed,
|
PyprojectDiscoveryStrategy::Fixed,
|
||||||
settings,
|
settings,
|
||||||
|
@ -41,6 +43,10 @@ pub fn resolve(
|
||||||
.transpose()?
|
.transpose()?
|
||||||
{
|
{
|
||||||
let settings = resolve_settings_with_processor(&pyproject, &Relativity::Cwd, overrides)?;
|
let settings = resolve_settings_with_processor(&pyproject, &Relativity::Cwd, overrides)?;
|
||||||
|
debug!(
|
||||||
|
"Using user specified pyproject.toml at {}",
|
||||||
|
pyproject.display()
|
||||||
|
);
|
||||||
return Ok(PyprojectConfig::new(
|
return Ok(PyprojectConfig::new(
|
||||||
PyprojectDiscoveryStrategy::Fixed,
|
PyprojectDiscoveryStrategy::Fixed,
|
||||||
settings,
|
settings,
|
||||||
|
@ -58,6 +64,7 @@ pub fn resolve(
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.unwrap_or(&path_dedot::CWD.as_path()),
|
.unwrap_or(&path_dedot::CWD.as_path()),
|
||||||
)? {
|
)? {
|
||||||
|
debug!("Using pyproject.toml (parent) at {}", pyproject.display());
|
||||||
let settings = resolve_settings_with_processor(&pyproject, &Relativity::Parent, overrides)?;
|
let settings = resolve_settings_with_processor(&pyproject, &Relativity::Parent, overrides)?;
|
||||||
return Ok(PyprojectConfig::new(
|
return Ok(PyprojectConfig::new(
|
||||||
PyprojectDiscoveryStrategy::Hierarchical,
|
PyprojectDiscoveryStrategy::Hierarchical,
|
||||||
|
@ -71,6 +78,7 @@ pub fn resolve(
|
||||||
// end up the "closest" `pyproject.toml` file for every Python file later on, so
|
// end up the "closest" `pyproject.toml` file for every Python file later on, so
|
||||||
// these act as the "default" settings.)
|
// these act as the "default" settings.)
|
||||||
if let Some(pyproject) = pyproject::find_user_settings_toml() {
|
if let Some(pyproject) = pyproject::find_user_settings_toml() {
|
||||||
|
debug!("Using pyproject.toml (cwd) at {}", pyproject.display());
|
||||||
let settings = resolve_settings_with_processor(&pyproject, &Relativity::Cwd, overrides)?;
|
let settings = resolve_settings_with_processor(&pyproject, &Relativity::Cwd, overrides)?;
|
||||||
return Ok(PyprojectConfig::new(
|
return Ok(PyprojectConfig::new(
|
||||||
PyprojectDiscoveryStrategy::Hierarchical,
|
PyprojectDiscoveryStrategy::Hierarchical,
|
||||||
|
@ -83,6 +91,7 @@ pub fn resolve(
|
||||||
// current working directory. (With `Strategy::Hierarchical`, we'll end up the
|
// current working directory. (With `Strategy::Hierarchical`, we'll end up the
|
||||||
// "closest" `pyproject.toml` file for every Python file later on, so these act
|
// "closest" `pyproject.toml` file for every Python file later on, so these act
|
||||||
// as the "default" settings.)
|
// as the "default" settings.)
|
||||||
|
debug!("Using Ruff default settings");
|
||||||
let mut config = Configuration::default();
|
let mut config = Configuration::default();
|
||||||
overrides.process_config(&mut config);
|
overrides.process_config(&mut config);
|
||||||
let settings = AllSettings::from_configuration(config, &path_dedot::CWD)?;
|
let settings = AllSettings::from_configuration(config, &path_dedot::CWD)?;
|
||||||
|
|
|
@ -4,9 +4,10 @@ use ignore::DirEntry;
|
||||||
use indicatif::ProgressBar;
|
use indicatif::ProgressBar;
|
||||||
use log::debug;
|
use log::debug;
|
||||||
use rayon::iter::{IntoParallelIterator, ParallelIterator};
|
use rayon::iter::{IntoParallelIterator, ParallelIterator};
|
||||||
|
use ruff::logging::{set_up_logging, LogLevel};
|
||||||
use ruff::resolver::python_files_in_path;
|
use ruff::resolver::python_files_in_path;
|
||||||
use ruff::settings::types::{FilePattern, FilePatternSet};
|
use ruff::settings::types::{FilePattern, FilePatternSet};
|
||||||
use ruff_cli::args::CheckArgs;
|
use ruff_cli::args::{CheckArgs, LogLevelArgs};
|
||||||
use ruff_cli::resolve::resolve;
|
use ruff_cli::resolve::resolve;
|
||||||
use ruff_formatter::{FormatError, LineWidth, PrintError};
|
use ruff_formatter::{FormatError, LineWidth, PrintError};
|
||||||
use ruff_python_formatter::{
|
use ruff_python_formatter::{
|
||||||
|
@ -178,9 +179,14 @@ pub(crate) struct Args {
|
||||||
/// Write all errors to this file in addition to stdout. Only used in multi-project mode.
|
/// Write all errors to this file in addition to stdout. Only used in multi-project mode.
|
||||||
#[arg(long)]
|
#[arg(long)]
|
||||||
pub(crate) error_file: Option<PathBuf>,
|
pub(crate) error_file: Option<PathBuf>,
|
||||||
|
#[clap(flatten)]
|
||||||
|
pub(crate) log_level_args: LogLevelArgs,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn main(args: &Args) -> anyhow::Result<ExitCode> {
|
pub(crate) fn main(args: &Args) -> anyhow::Result<ExitCode> {
|
||||||
|
let log_level = LogLevel::from(&args.log_level_args);
|
||||||
|
set_up_logging(&log_level)?;
|
||||||
|
|
||||||
let all_success = if args.multi_project {
|
let all_success = if args.multi_project {
|
||||||
format_dev_multi_project(args)?
|
format_dev_multi_project(args)?
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue