Print warning when running debug builds without --no-cache (#1549)

This commit is contained in:
Martin Fischer
2023-01-02 18:12:04 +01:00
committed by GitHub
parent 07e47bef4b
commit f52691a90a
2 changed files with 25 additions and 8 deletions

View File

@@ -46,8 +46,8 @@ pub fn run(
if paths.is_empty() {
one_time_warning!(
"{} {}",
"warning:".yellow().bold(),
"{}: {}",
"warning".yellow().bold(),
"No Python files found under the given path(s)"
);
return Ok(Diagnostics::default());
@@ -196,8 +196,8 @@ pub fn add_noqa(
if paths.is_empty() {
one_time_warning!(
"{} {}",
"warning:".yellow().bold(),
"{}: {}",
"warning".yellow().bold(),
"No Python files found under the given path(s)"
);
return Ok(0);
@@ -270,8 +270,8 @@ pub fn show_files(
if paths.is_empty() {
one_time_warning!(
"{} {}",
"warning:".yellow().bold(),
"{}: {}",
"warning".yellow().bold(),
"No Python files found under the given path(s)"
);
return Ok(());

View File

@@ -29,6 +29,7 @@ use ::ruff::settings::{pyproject, Settings};
use ::ruff::updates;
use anyhow::Result;
use clap::{CommandFactory, Parser};
use colored::Colorize;
use notify::{recommended_watcher, RecursiveMode, Watcher};
use path_absolutize::path_dedot;
@@ -172,13 +173,29 @@ pub(crate) fn inner_main() -> Result<ExitCode> {
};
let cache = !cli.no_cache;
#[cfg(debug_assertions)]
if cache {
// `--no-cache` doesn't respect code changes, and so is often confusing during
// development.
eprintln!(
"{}: debug build without --no-cache.",
"warning".yellow().bold()
);
}
let printer = Printer::new(&format, &log_level, &autofix, &violations);
if cli.watch {
if !matches!(autofix, fixer::Mode::None) {
eprintln!("Warning: --fix is not enabled in watch mode.");
eprintln!(
"{}: --fix is not enabled in watch mode.",
"warning".yellow().bold()
);
}
if format != SerializationFormat::Text {
eprintln!("Warning: --format 'text' is used in watch mode.");
eprintln!(
"{}: --format 'text' is used in watch mode.",
"warning".yellow().bold()
);
}
// Perform an initial run instantly.