Include hidden ecosystem_ci option to show fixes without feature (#4528)

This commit is contained in:
konstin 2023-05-24 04:22:23 +02:00 committed by GitHub
parent b1d01b1950
commit 3644695bf2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 8 additions and 19 deletions

View File

@ -83,4 +83,3 @@ colored = { workspace = true, features = ["no-color"] }
default = [] default = []
schemars = ["dep:schemars"] schemars = ["dep:schemars"]
jupyter_notebook = [] jupyter_notebook = []
ecosystem_ci = []

View File

@ -66,7 +66,6 @@ ureq = { version = "2.6.2", features = [] }
[features] [features]
jupyter_notebook = ["ruff/jupyter_notebook"] jupyter_notebook = ["ruff/jupyter_notebook"]
ecosystem_ci = ["ruff/ecosystem_ci"]
[target.'cfg(target_os = "windows")'.dependencies] [target.'cfg(target_os = "windows")'.dependencies]
mimalloc = "0.1.34" mimalloc = "0.1.34"

View File

@ -325,7 +325,6 @@ pub struct CheckArgs {
)] )]
pub show_settings: bool, pub show_settings: bool,
/// Dev-only argument to show fixes /// Dev-only argument to show fixes
#[cfg(feature = "ecosystem_ci")]
#[arg(long, hide = true)] #[arg(long, hide = true)]
pub ecosystem_ci: bool, pub ecosystem_ci: bool,
} }

View File

@ -254,7 +254,6 @@ mod test {
LogLevel::Default, LogLevel::Default,
FixMode::None, FixMode::None,
Flags::SHOW_VIOLATIONS, Flags::SHOW_VIOLATIONS,
#[cfg(feature = "ecosystem_ci")]
false, false,
); );
let mut writer: Vec<u8> = Vec::new(); let mut writer: Vec<u8> = Vec::new();

View File

@ -155,8 +155,13 @@ fn format(files: &[PathBuf]) -> Result<ExitStatus> {
} }
fn check(args: CheckArgs, log_level: LogLevel) -> Result<ExitStatus> { fn check(args: CheckArgs, log_level: LogLevel) -> Result<ExitStatus> {
#[cfg(feature = "ecosystem_ci")]
let ecosystem_ci = args.ecosystem_ci; let ecosystem_ci = args.ecosystem_ci;
if ecosystem_ci {
warn_user_once!(
"The formatting of fixes emitted by this option is a work-in-progress, subject to \
change at any time, and intended for use with the ecosystem ci scripts only."
);
}
let (cli, overrides) = args.partition(); let (cli, overrides) = args.partition();
// Construct the "default" settings. These are used when no `pyproject.toml` // Construct the "default" settings. These are used when no `pyproject.toml`
@ -243,14 +248,7 @@ fn check(args: CheckArgs, log_level: LogLevel) -> Result<ExitStatus> {
return Ok(ExitStatus::Success); return Ok(ExitStatus::Success);
} }
let printer = Printer::new( let printer = Printer::new(format, log_level, autofix, printer_flags, ecosystem_ci);
format,
log_level,
autofix,
printer_flags,
#[cfg(feature = "ecosystem_ci")]
ecosystem_ci,
);
if cli.watch { if cli.watch {
if format != SerializationFormat::Text { if format != SerializationFormat::Text {

View File

@ -71,7 +71,6 @@ pub(crate) struct Printer {
autofix_level: flags::FixMode, autofix_level: flags::FixMode,
flags: Flags, flags: Flags,
/// Dev-only argument to show fixes /// Dev-only argument to show fixes
#[cfg(feature = "ecosystem_ci")]
ecosystem_ci: bool, ecosystem_ci: bool,
} }
@ -81,14 +80,13 @@ impl Printer {
log_level: LogLevel, log_level: LogLevel,
autofix_level: flags::FixMode, autofix_level: flags::FixMode,
flags: Flags, flags: Flags,
#[cfg(feature = "ecosystem_ci")] ecosystem_ci: bool, ecosystem_ci: bool,
) -> Self { ) -> Self {
Self { Self {
format, format,
log_level, log_level,
autofix_level, autofix_level,
flags, flags,
#[cfg(feature = "ecosystem_ci")]
ecosystem_ci, ecosystem_ci,
} }
} }
@ -189,10 +187,7 @@ impl Printer {
JunitEmitter::default().emit(writer, &diagnostics.messages, &context)?; JunitEmitter::default().emit(writer, &diagnostics.messages, &context)?;
} }
SerializationFormat::Text => { SerializationFormat::Text => {
#[cfg(feature = "ecosystem_ci")]
let show_fixes = self.ecosystem_ci && self.flags.contains(Flags::SHOW_FIXES); let show_fixes = self.ecosystem_ci && self.flags.contains(Flags::SHOW_FIXES);
#[cfg(not(feature = "ecosystem_ci"))]
let show_fixes = false;
TextEmitter::default() TextEmitter::default()
.with_show_fix_status(show_fix_status(self.autofix_level)) .with_show_fix_status(show_fix_status(self.autofix_level))