From c7e4e41a7ae62a1dd99efb3e1d26dc29318951bd Mon Sep 17 00:00:00 2001 From: Charlie Marsh Date: Sat, 7 Jan 2023 00:30:25 -0500 Subject: [PATCH] Revert "Include list of fixed files in `stderr` output (#1701)" (#1711) This reverts commit 53ed52dc59679f0207da5059e05d849736e1b76d. I want to get some feedback on this before I send it out. --- src/commands.rs | 3 +-- src/linter.rs | 5 ----- src/logging.rs | 4 ++-- src/main_native.rs | 8 +++----- 4 files changed, 6 insertions(+), 14 deletions(-) diff --git a/src/commands.rs b/src/commands.rs index ee61c2c5b7..f3babf2913 100644 --- a/src/commands.rs +++ b/src/commands.rs @@ -36,7 +36,6 @@ pub fn run( overrides: &Overrides, cache: flags::Cache, autofix: fixer::Mode, - level: LogLevel, ) -> Result { // 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(( diff --git a/src/linter.rs b/src/linter.rs index 6c74bf9017..cd68e12d28 100644 --- a/src/linter.rs +++ b/src/linter.rs @@ -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 { // 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(); diff --git a/src/logging.rs b/src/logging.rs index 2ab0fcb313..97d34dfbbe 100644 --- a/src/logging.rs +++ b/src/logging.rs @@ -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, diff --git a/src/main_native.rs b/src/main_native.rs index 20d48bf615..c3dc064e9a 100644 --- a/src/main_native.rs +++ b/src/main_native.rs @@ -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 { &overrides, cache.into(), fixer::Mode::None, - log_level, )?; printer.write_continuously(&messages)?; @@ -233,7 +233,6 @@ pub(crate) fn inner_main() -> Result { &overrides, cache.into(), fixer::Mode::None, - log_level, )?; printer.write_continuously(&messages)?; } @@ -245,7 +244,7 @@ pub(crate) fn inner_main() -> Result { 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 { &overrides, cache.into(), autofix, - log_level, )? };