mirror of https://github.com/astral-sh/ruff
This reverts commit 53ed52dc59.
I want to get some feedback on this before I send it out.
This commit is contained in:
parent
311a823a4a
commit
c7e4e41a7a
|
|
@ -36,7 +36,6 @@ pub fn run(
|
|||
overrides: &Overrides,
|
||||
cache: flags::Cache,
|
||||
autofix: fixer::Mode,
|
||||
level: LogLevel,
|
||||
) -> Result<Diagnostics> {
|
||||
// Collect all the Python files to check.
|
||||
let start = Instant::now();
|
||||
|
|
@ -102,7 +101,7 @@ pub fn run(
|
|||
.and_then(|parent| package_roots.get(parent))
|
||||
.and_then(|package| *package);
|
||||
let settings = resolver.resolve(path, pyproject_strategy);
|
||||
lint_path(path, package, settings, cache, autofix, level)
|
||||
lint_path(path, package, settings, cache, autofix)
|
||||
.map_err(|e| (Some(path.to_owned()), e.to_string()))
|
||||
}
|
||||
Err(e) => Err((
|
||||
|
|
|
|||
|
|
@ -19,7 +19,6 @@ use crate::checkers::lines::check_lines;
|
|||
use crate::checkers::noqa::check_noqa;
|
||||
use crate::checkers::tokens::check_tokens;
|
||||
use crate::directives::Directives;
|
||||
use crate::logging::LogLevel;
|
||||
use crate::message::{Message, Source};
|
||||
use crate::noqa::add_noqa;
|
||||
use crate::registry::{Check, CheckCode, CheckKind, LintSource};
|
||||
|
|
@ -182,7 +181,6 @@ pub fn lint_path(
|
|||
settings: &Settings,
|
||||
cache: flags::Cache,
|
||||
autofix: fixer::Mode,
|
||||
level: LogLevel,
|
||||
) -> Result<Diagnostics> {
|
||||
// Validate the `Settings` and return any errors.
|
||||
settings.validate()?;
|
||||
|
|
@ -214,9 +212,6 @@ pub fn lint_path(
|
|||
let (transformed, fixed, messages) = lint_fix(&contents, path, package, settings)?;
|
||||
if fixed > 0 {
|
||||
if matches!(autofix, fixer::Mode::Apply) {
|
||||
if level >= LogLevel::Default {
|
||||
eprintln!("Fixing {fixed} error(s) in {}", fs::relativize_path(path));
|
||||
}
|
||||
write(path, transformed)?;
|
||||
} else if matches!(autofix, fixer::Mode::Diff) {
|
||||
let mut stdout = io::stdout().lock();
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ macro_rules! tell_user {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Copy, Clone, PartialOrd, Ord, PartialEq, Eq)]
|
||||
#[derive(Debug, PartialOrd, Ord, PartialEq, Eq)]
|
||||
pub enum LogLevel {
|
||||
// No output (+ `log::LevelFilter::Off`).
|
||||
Silent,
|
||||
|
|
@ -38,7 +38,7 @@ pub enum LogLevel {
|
|||
}
|
||||
|
||||
impl LogLevel {
|
||||
fn level_filter(self) -> log::LevelFilter {
|
||||
fn level_filter(&self) -> log::LevelFilter {
|
||||
match self {
|
||||
LogLevel::Default => log::LevelFilter::Info,
|
||||
LogLevel::Verbose => log::LevelFilter::Debug,
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ use std::sync::mpsc::channel;
|
|||
|
||||
use ::ruff::autofix::fixer;
|
||||
use ::ruff::cli::{extract_log_level, Cli, Overrides};
|
||||
use ::ruff::commands;
|
||||
use ::ruff::logging::{set_up_logging, LogLevel};
|
||||
use ::ruff::printer::{Printer, Violations};
|
||||
use ::ruff::resolver::{resolve_settings, FileDiscovery, PyprojectDiscovery, Relativity};
|
||||
|
|
@ -13,12 +14,12 @@ use ::ruff::settings::types::SerializationFormat;
|
|||
use ::ruff::settings::{pyproject, Settings};
|
||||
#[cfg(feature = "update-informer")]
|
||||
use ::ruff::updates;
|
||||
use ::ruff::{commands, one_time_warning};
|
||||
use anyhow::Result;
|
||||
use clap::{CommandFactory, Parser};
|
||||
use colored::Colorize;
|
||||
use notify::{recommended_watcher, RecursiveMode, Watcher};
|
||||
use path_absolutize::path_dedot;
|
||||
use ruff::one_time_warning;
|
||||
|
||||
/// Resolve the relevant settings strategy and defaults for the current
|
||||
/// invocation.
|
||||
|
|
@ -202,7 +203,6 @@ pub(crate) fn inner_main() -> Result<ExitCode> {
|
|||
&overrides,
|
||||
cache.into(),
|
||||
fixer::Mode::None,
|
||||
log_level,
|
||||
)?;
|
||||
printer.write_continuously(&messages)?;
|
||||
|
||||
|
|
@ -233,7 +233,6 @@ pub(crate) fn inner_main() -> Result<ExitCode> {
|
|||
&overrides,
|
||||
cache.into(),
|
||||
fixer::Mode::None,
|
||||
log_level,
|
||||
)?;
|
||||
printer.write_continuously(&messages)?;
|
||||
}
|
||||
|
|
@ -245,7 +244,7 @@ pub(crate) fn inner_main() -> Result<ExitCode> {
|
|||
let modifications =
|
||||
commands::add_noqa(&cli.files, &pyproject_strategy, &file_strategy, &overrides)?;
|
||||
if modifications > 0 && log_level >= LogLevel::Default {
|
||||
eprintln!("Added {modifications} noqa directives.");
|
||||
println!("Added {modifications} noqa directives.");
|
||||
}
|
||||
} else {
|
||||
let is_stdin = cli.files == vec![PathBuf::from("-")];
|
||||
|
|
@ -267,7 +266,6 @@ pub(crate) fn inner_main() -> Result<ExitCode> {
|
|||
&overrides,
|
||||
cache.into(),
|
||||
autofix,
|
||||
log_level,
|
||||
)?
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue