From e74f6790e93ff2a2c01b8b89dacc3b9cdb8f6fca Mon Sep 17 00:00:00 2001 From: Tibor Reiss Date: Thu, 8 Feb 2024 20:16:31 +0100 Subject: [PATCH 1/2] Remove deprecated configurations 'show-source' and 'no-show-source' --- crates/ruff/src/args.rs | 36 +------ crates/ruff/tests/deprecation.rs | 118 +-------------------- crates/ruff_workspace/src/configuration.rs | 13 --- crates/ruff_workspace/src/options.rs | 15 --- docs/configuration.md | 4 - ruff.schema.json | 8 -- 6 files changed, 5 insertions(+), 189 deletions(-) diff --git a/crates/ruff/src/args.rs b/crates/ruff/src/args.rs index 77399ee2db0b2..cc2f9b43d168d 100644 --- a/crates/ruff/src/args.rs +++ b/crates/ruff/src/args.rs @@ -160,13 +160,6 @@ pub struct CheckCommand { unsafe_fixes: bool, #[arg(long, overrides_with("unsafe_fixes"), hide = true)] no_unsafe_fixes: bool, - /// Show violations with source code. - /// Use `--no-show-source` to disable. - /// (Deprecated: use `--output-format=full` or `--output-format=concise` instead of `--show-source` and `--no-show-source`, respectively) - #[arg(long, overrides_with("no_show_source"))] - show_source: bool, - #[clap(long, overrides_with("show_source"), hide = true)] - no_show_source: bool, /// Show an enumeration of all fixed lint violations. /// Use `--no-show-fixes` to disable. #[arg(long, overrides_with("no_show_fixes"))] @@ -365,7 +358,6 @@ pub struct CheckCommand { long, // Unsupported default-command arguments. conflicts_with = "diff", - conflicts_with = "show_source", conflicts_with = "watch", )] pub statistics: bool, @@ -703,7 +695,6 @@ impl CheckCommand { force_exclude: resolve_bool_arg(self.force_exclude, self.no_force_exclude), output_format: resolve_output_format( self.output_format, - resolve_bool_arg(self.show_source, self.no_show_source), resolve_bool_arg(self.preview, self.no_preview).unwrap_or_default(), ), show_fixes: resolve_bool_arg(self.show_fixes, self.no_show_fixes), @@ -935,32 +926,11 @@ The path `{value}` does not point to a configuration file" fn resolve_output_format( output_format: Option, - show_sources: Option, preview: bool, ) -> Option { - Some(match (output_format, show_sources) { - (Some(o), None) => o, - (Some(SerializationFormat::Grouped), Some(true)) => { - warn_user!("`--show-source` with `--output-format=grouped` is deprecated, and will not show source files. Use `--output-format=full` to show source information."); - SerializationFormat::Grouped - } - (Some(fmt), Some(true)) => { - warn_user!("The `--show-source` argument is deprecated and has been ignored in favor of `--output-format={fmt}`."); - fmt - } - (Some(fmt), Some(false)) => { - warn_user!("The `--no-show-source` argument is deprecated and has been ignored in favor of `--output-format={fmt}`."); - fmt - } - (None, Some(true)) => { - warn_user!("The `--show-source` argument is deprecated. Use `--output-format=full` instead."); - SerializationFormat::Full - } - (None, Some(false)) => { - warn_user!("The `--no-show-source` argument is deprecated. Use `--output-format=concise` instead."); - SerializationFormat::Concise - } - (None, None) => return None + Some(match output_format { + Some(o) => o, + None => return None }).map(|format| match format { SerializationFormat::Text => { warn_user!("`--output-format=text` is deprecated. Use `--output-format=full` or `--output-format=concise` instead. `text` will be treated as `{}`.", SerializationFormat::default(preview)); diff --git a/crates/ruff/tests/deprecation.rs b/crates/ruff/tests/deprecation.rs index 339adc549dae7..ea5aad2a75115 100644 --- a/crates/ruff/tests/deprecation.rs +++ b/crates/ruff/tests/deprecation.rs @@ -9,134 +9,21 @@ const BIN_NAME: &str = "ruff"; const STDIN: &str = "l = 1"; -fn ruff_check(show_source: Option, output_format: Option) -> Command { +fn ruff_check(output_format: Option) -> Command { let mut cmd = Command::new(get_cargo_bin(BIN_NAME)); let output_format = output_format.unwrap_or(format!("{}", SerializationFormat::default(false))); cmd.arg("check") .arg("--output-format") .arg(output_format) .arg("--no-cache"); - match show_source { - Some(true) => { - cmd.arg("--show-source"); - } - Some(false) => { - cmd.arg("--no-show-source"); - } - None => {} - } cmd.arg("-"); cmd } -#[test] -fn ensure_show_source_is_deprecated() { - assert_cmd_snapshot!(ruff_check(Some(true), None).pass_stdin(STDIN), @r###" - success: false - exit_code: 1 - ----- stdout ----- - -:1:1: E741 Ambiguous variable name: `l` - Found 1 error. - - ----- stderr ----- - warning: The `--show-source` argument is deprecated and has been ignored in favor of `--output-format=concise`. - "###); -} - -#[test] -fn ensure_no_show_source_is_deprecated() { - assert_cmd_snapshot!(ruff_check(Some(false), None).pass_stdin(STDIN), @r###" - success: false - exit_code: 1 - ----- stdout ----- - -:1:1: E741 Ambiguous variable name: `l` - Found 1 error. - - ----- stderr ----- - warning: The `--no-show-source` argument is deprecated and has been ignored in favor of `--output-format=concise`. - "###); -} - #[test] fn ensure_output_format_is_deprecated() { - assert_cmd_snapshot!(ruff_check(None, Some("text".into())).pass_stdin(STDIN), @r###" - success: false - exit_code: 1 - ----- stdout ----- - -:1:1: E741 Ambiguous variable name: `l` - Found 1 error. - - ----- stderr ----- - warning: `--output-format=text` is deprecated. Use `--output-format=full` or `--output-format=concise` instead. `text` will be treated as `concise`. - "###); -} - -#[test] -fn ensure_output_format_overrides_show_source() { - assert_cmd_snapshot!(ruff_check(Some(true), Some("concise".into())).pass_stdin(STDIN), @r###" - success: false - exit_code: 1 - ----- stdout ----- - -:1:1: E741 Ambiguous variable name: `l` - Found 1 error. - - ----- stderr ----- - warning: The `--show-source` argument is deprecated and has been ignored in favor of `--output-format=concise`. - "###); -} - -#[test] -fn ensure_full_output_format_overrides_no_show_source() { - assert_cmd_snapshot!(ruff_check(Some(false), Some("full".into())).pass_stdin(STDIN), @r###" - success: false - exit_code: 1 - ----- stdout ----- - -:1:1: E741 Ambiguous variable name: `l` - | - 1 | l = 1 - | ^ E741 - | - - Found 1 error. - - ----- stderr ----- - warning: The `--no-show-source` argument is deprecated and has been ignored in favor of `--output-format=full`. - "###); -} - -#[test] -fn ensure_output_format_uses_concise_over_no_show_source() { - assert_cmd_snapshot!(ruff_check(Some(false), Some("concise".into())).pass_stdin(STDIN), @r###" - success: false - exit_code: 1 - ----- stdout ----- - -:1:1: E741 Ambiguous variable name: `l` - Found 1 error. - - ----- stderr ----- - warning: The `--no-show-source` argument is deprecated and has been ignored in favor of `--output-format=concise`. - "###); -} - -#[test] -fn ensure_deprecated_output_format_overrides_show_source() { - assert_cmd_snapshot!(ruff_check(Some(true), Some("text".into())).pass_stdin(STDIN), @r###" - success: false - exit_code: 1 - ----- stdout ----- - -:1:1: E741 Ambiguous variable name: `l` - Found 1 error. - - ----- stderr ----- - warning: The `--show-source` argument is deprecated and has been ignored in favor of `--output-format=text`. - warning: `--output-format=text` is deprecated. Use `--output-format=full` or `--output-format=concise` instead. `text` will be treated as `concise`. - "###); -} - -#[test] -fn ensure_deprecated_output_format_overrides_no_show_source() { - assert_cmd_snapshot!(ruff_check(Some(false), Some("text".into())).pass_stdin(STDIN), @r###" + assert_cmd_snapshot!(ruff_check(Some("text".into())).pass_stdin(STDIN), @r###" success: false exit_code: 1 ----- stdout ----- @@ -144,7 +31,6 @@ fn ensure_deprecated_output_format_overrides_no_show_source() { Found 1 error. ----- stderr ----- - warning: The `--no-show-source` argument is deprecated and has been ignored in favor of `--output-format=text`. warning: `--output-format=text` is deprecated. Use `--output-format=full` or `--output-format=concise` instead. `text` will be treated as `concise`. "###); } diff --git a/crates/ruff_workspace/src/configuration.rs b/crates/ruff_workspace/src/configuration.rs index 7cb2a5c5083fc..bde13db0eea81 100644 --- a/crates/ruff_workspace/src/configuration.rs +++ b/crates/ruff_workspace/src/configuration.rs @@ -431,12 +431,6 @@ impl Configuration { #[allow(deprecated)] let output_format = { - if options.show_source.is_some() { - warn_user_once!( - r#"The `show-source` option has been deprecated in favor of `output-format`'s "full" and "concise" variants. Please update your configuration to use `output-format = ` instead."# - ); - } - options .output_format .map(|format| match format { @@ -446,13 +440,6 @@ impl Configuration { }, other => other }) - .or(options.show_source.map(|show_source| { - if show_source { - SerializationFormat::Full - } else { - SerializationFormat::Concise - } - })) }; Ok(Self { diff --git a/crates/ruff_workspace/src/options.rs b/crates/ruff_workspace/src/options.rs index f227d2dfdab67..4f26746e32e19 100644 --- a/crates/ruff_workspace/src/options.rs +++ b/crates/ruff_workspace/src/options.rs @@ -108,21 +108,6 @@ pub struct Options { #[option(default = "false", value_type = "bool", example = "fix-only = true")] pub fix_only: Option, - /// Whether to show source code snippets when reporting lint violations - /// (overridden by the `--show-source` command-line flag). - #[option( - default = "false", - value_type = "bool", - example = r#" - # By default, always show source code snippets. - show-source = true - "# - )] - #[deprecated( - note = "`show-source` is deprecated and is now part of `output-format` in the form of `full` or `concise` options. Please update your configuration." - )] - pub show_source: Option, - /// Whether to show an enumeration of all fixed lint violations /// (overridden by the `--show-fixes` command-line flag). #[option( diff --git a/docs/configuration.md b/docs/configuration.md index 949e22f8801fd..3749325b03fed 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -576,10 +576,6 @@ Options: --unsafe-fixes Include fixes that may not retain the original intent of the code. Use `--no-unsafe-fixes` to disable - --show-source - Show violations with source code. Use `--no-show-source` to disable. - (Deprecated: use `--output-format=full` or `--output-format=concise` - instead of `--show-source` and `--no-show-source`, respectively) --show-fixes Show an enumeration of all fixed lint violations. Use `--no-show-fixes` to disable diff --git a/ruff.schema.json b/ruff.schema.json index 15779c1222558..6a5eb454fbbbb 100644 --- a/ruff.schema.json +++ b/ruff.schema.json @@ -670,14 +670,6 @@ "null" ] }, - "show-source": { - "description": "Whether to show source code snippets when reporting lint violations (overridden by the `--show-source` command-line flag).", - "deprecated": true, - "type": [ - "boolean", - "null" - ] - }, "src": { "description": "The directories to consider when resolving first- vs. third-party imports.\n\nAs an example: given a Python package structure like:\n\n```text my_project ├── pyproject.toml └── src └── my_package ├── __init__.py ├── foo.py └── bar.py ```\n\nThe `./src` directory should be included in the `src` option (e.g., `src = [\"src\"]`), such that when resolving imports, `my_package.foo` is considered a first-party import.\n\nWhen omitted, the `src` directory will typically default to the directory containing the nearest `pyproject.toml`, `ruff.toml`, or `.ruff.toml` file (the \"project root\"), unless a configuration file is explicitly provided (e.g., via the `--config` command-line flag).\n\nThis field supports globs. For example, if you have a series of Python packages in a `python_modules` directory, `src = [\"python_modules/*\"]` would expand to incorporate all of the packages in that directory. User home directory and environment variables will also be expanded.", "type": [ From 2f5817ef64a27c152a01edddf2b272c5c4d9496a Mon Sep 17 00:00:00 2001 From: Micha Reiser Date: Mon, 24 Jun 2024 10:43:44 +0200 Subject: [PATCH 2/2] Rename `SerializationFormat` to `OutputFormat` --- crates/ruff/src/args.rs | 18 ++++---- crates/ruff/src/lib.rs | 6 +-- crates/ruff/src/printer.rs | 48 +++++++++++----------- crates/ruff/tests/deprecation.rs | 4 +- crates/ruff_linter/src/settings/types.rs | 6 +-- crates/ruff_workspace/src/configuration.rs | 15 ++++--- crates/ruff_workspace/src/options.rs | 4 +- crates/ruff_workspace/src/settings.rs | 6 +-- ruff.schema.json | 38 ++++++++--------- 9 files changed, 71 insertions(+), 74 deletions(-) diff --git a/crates/ruff/src/args.rs b/crates/ruff/src/args.rs index cc2f9b43d168d..162ccd912462b 100644 --- a/crates/ruff/src/args.rs +++ b/crates/ruff/src/args.rs @@ -18,8 +18,8 @@ use ruff_linter::line_width::LineLength; use ruff_linter::logging::LogLevel; use ruff_linter::registry::Rule; use ruff_linter::settings::types::{ - ExtensionPair, FilePattern, PatternPrefixPair, PerFileIgnore, PreviewMode, PythonVersion, - SerializationFormat, UnsafeFixes, + ExtensionPair, FilePattern, OutputFormat, PatternPrefixPair, PerFileIgnore, PreviewMode, + PythonVersion, UnsafeFixes, }; use ruff_linter::{warn_user, RuleParser, RuleSelector, RuleSelectorParser}; use ruff_source_file::{LineIndex, OneIndexed}; @@ -187,7 +187,7 @@ pub struct CheckCommand { /// The default serialization format is "concise". /// In preview mode, the default serialization format is "full". #[arg(long, value_enum, env = "RUFF_OUTPUT_FORMAT")] - pub output_format: Option, + pub output_format: Option, /// Specify file to write the linter output to (default: stdout). #[arg(short, long, env = "RUFF_OUTPUT_FILE")] @@ -925,16 +925,16 @@ The path `{value}` does not point to a configuration file" } fn resolve_output_format( - output_format: Option, + output_format: Option, preview: bool, -) -> Option { +) -> Option { Some(match output_format { Some(o) => o, None => return None }).map(|format| match format { - SerializationFormat::Text => { - warn_user!("`--output-format=text` is deprecated. Use `--output-format=full` or `--output-format=concise` instead. `text` will be treated as `{}`.", SerializationFormat::default(preview)); - SerializationFormat::default(preview) + OutputFormat::Text => { + warn_user!("`--output-format=text` is deprecated. Use `--output-format=full` or `--output-format=concise` instead. `text` will be treated as `{}`.", OutputFormat::default(preview)); + OutputFormat::default(preview) }, other => other }) @@ -1189,7 +1189,7 @@ struct ExplicitConfigOverrides { fix_only: Option, unsafe_fixes: Option, force_exclude: Option, - output_format: Option, + output_format: Option, show_fixes: Option, extension: Option>, } diff --git a/crates/ruff/src/lib.rs b/crates/ruff/src/lib.rs index 7281a3be87266..2bada3e6df389 100644 --- a/crates/ruff/src/lib.rs +++ b/crates/ruff/src/lib.rs @@ -16,7 +16,7 @@ use notify::{recommended_watcher, RecursiveMode, Watcher}; use ruff_linter::logging::{set_up_logging, LogLevel}; use ruff_linter::settings::flags::FixMode; -use ruff_linter::settings::types::SerializationFormat; +use ruff_linter::settings::types::OutputFormat; use ruff_linter::{fs, warn_user, warn_user_once}; use ruff_workspace::Settings; @@ -351,10 +351,10 @@ pub fn check(args: CheckCommand, global_options: GlobalConfigArgs) -> Result for SerializeRuleAsCode { } pub(crate) struct Printer { - format: SerializationFormat, + format: OutputFormat, log_level: LogLevel, fix_mode: flags::FixMode, unsafe_fixes: UnsafeFixes, @@ -76,7 +76,7 @@ pub(crate) struct Printer { impl Printer { pub(crate) const fn new( - format: SerializationFormat, + format: OutputFormat, log_level: LogLevel, fix_mode: flags::FixMode, unsafe_fixes: UnsafeFixes, @@ -219,10 +219,10 @@ impl Printer { if !self.flags.intersects(Flags::SHOW_VIOLATIONS) { if matches!( self.format, - SerializationFormat::Text - | SerializationFormat::Full - | SerializationFormat::Concise - | SerializationFormat::Grouped + OutputFormat::Text + | OutputFormat::Full + | OutputFormat::Concise + | OutputFormat::Grouped ) { if self.flags.intersects(Flags::SHOW_FIX_SUMMARY) { if !diagnostics.fixed.is_empty() { @@ -240,24 +240,24 @@ impl Printer { let fixables = FixableStatistics::try_from(diagnostics, self.unsafe_fixes); match self.format { - SerializationFormat::Json => { + OutputFormat::Json => { JsonEmitter.emit(writer, &diagnostics.messages, &context)?; } - SerializationFormat::Rdjson => { + OutputFormat::Rdjson => { RdjsonEmitter.emit(writer, &diagnostics.messages, &context)?; } - SerializationFormat::JsonLines => { + OutputFormat::JsonLines => { JsonLinesEmitter.emit(writer, &diagnostics.messages, &context)?; } - SerializationFormat::Junit => { + OutputFormat::Junit => { JunitEmitter.emit(writer, &diagnostics.messages, &context)?; } - SerializationFormat::Concise - | SerializationFormat::Full => { + OutputFormat::Concise + | OutputFormat::Full => { TextEmitter::default() .with_show_fix_status(show_fix_status(self.fix_mode, fixables.as_ref())) .with_show_fix_diff(self.flags.intersects(Flags::SHOW_FIX_DIFF)) - .with_show_source(self.format == SerializationFormat::Full) + .with_show_source(self.format == OutputFormat::Full) .with_unsafe_fixes(self.unsafe_fixes) .emit(writer, &diagnostics.messages, &context)?; @@ -271,7 +271,7 @@ impl Printer { self.write_summary_text(writer, diagnostics)?; } - SerializationFormat::Grouped => { + OutputFormat::Grouped => { GroupedEmitter::default() .with_show_fix_status(show_fix_status(self.fix_mode, fixables.as_ref())) .with_unsafe_fixes(self.unsafe_fixes) @@ -286,22 +286,22 @@ impl Printer { } self.write_summary_text(writer, diagnostics)?; } - SerializationFormat::Github => { + OutputFormat::Github => { GithubEmitter.emit(writer, &diagnostics.messages, &context)?; } - SerializationFormat::Gitlab => { + OutputFormat::Gitlab => { GitlabEmitter::default().emit(writer, &diagnostics.messages, &context)?; } - SerializationFormat::Pylint => { + OutputFormat::Pylint => { PylintEmitter.emit(writer, &diagnostics.messages, &context)?; } - SerializationFormat::Azure => { + OutputFormat::Azure => { AzureEmitter.emit(writer, &diagnostics.messages, &context)?; } - SerializationFormat::Sarif => { + OutputFormat::Sarif => { SarifEmitter.emit(writer, &diagnostics.messages, &context)?; } - SerializationFormat::Text => unreachable!("Text is deprecated and should have been automatically converted to the default serialization format") + OutputFormat::Text => unreachable!("Text is deprecated and should have been automatically converted to the default serialization format") } writer.flush()?; @@ -350,9 +350,7 @@ impl Printer { } match self.format { - SerializationFormat::Text - | SerializationFormat::Full - | SerializationFormat::Concise => { + OutputFormat::Text | OutputFormat::Full | OutputFormat::Concise => { // Compute the maximum number of digits in the count and code, for all messages, // to enable pretty-printing. let count_width = num_digits( @@ -393,7 +391,7 @@ impl Printer { } return Ok(()); } - SerializationFormat::Json => { + OutputFormat::Json => { writeln!(writer, "{}", serde_json::to_string_pretty(&statistics)?)?; } _ => { diff --git a/crates/ruff/tests/deprecation.rs b/crates/ruff/tests/deprecation.rs index ea5aad2a75115..b78ee9f3b1741 100644 --- a/crates/ruff/tests/deprecation.rs +++ b/crates/ruff/tests/deprecation.rs @@ -1,6 +1,6 @@ //! A test suite that ensures deprecated command line options have appropriate warnings / behaviors -use ruff_linter::settings::types::SerializationFormat; +use ruff_linter::settings::types::OutputFormat; use std::process::Command; use insta_cmd::{assert_cmd_snapshot, get_cargo_bin}; @@ -11,7 +11,7 @@ const STDIN: &str = "l = 1"; fn ruff_check(output_format: Option) -> Command { let mut cmd = Command::new(get_cargo_bin(BIN_NAME)); - let output_format = output_format.unwrap_or(format!("{}", SerializationFormat::default(false))); + let output_format = output_format.unwrap_or(format!("{}", OutputFormat::default(false))); cmd.arg("check") .arg("--output-format") .arg(output_format) diff --git a/crates/ruff_linter/src/settings/types.rs b/crates/ruff_linter/src/settings/types.rs index 25f7223b76aea..39ec68142680c 100644 --- a/crates/ruff_linter/src/settings/types.rs +++ b/crates/ruff_linter/src/settings/types.rs @@ -504,7 +504,7 @@ impl FromIterator for ExtensionMapping { #[cfg_attr(feature = "clap", derive(clap::ValueEnum))] #[serde(rename_all = "kebab-case")] #[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] -pub enum SerializationFormat { +pub enum OutputFormat { Text, Concise, Full, @@ -520,7 +520,7 @@ pub enum SerializationFormat { Sarif, } -impl Display for SerializationFormat { +impl Display for OutputFormat { fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { match self { Self::Text => write!(f, "text"), @@ -540,7 +540,7 @@ impl Display for SerializationFormat { } } -impl SerializationFormat { +impl OutputFormat { pub fn default(preview: bool) -> Self { if preview { Self::Full diff --git a/crates/ruff_workspace/src/configuration.rs b/crates/ruff_workspace/src/configuration.rs index bde13db0eea81..a278f77307a5f 100644 --- a/crates/ruff_workspace/src/configuration.rs +++ b/crates/ruff_workspace/src/configuration.rs @@ -27,8 +27,8 @@ use ruff_linter::rules::pycodestyle; use ruff_linter::settings::fix_safety_table::FixSafetyTable; use ruff_linter::settings::rule_table::RuleTable; use ruff_linter::settings::types::{ - CompiledPerFileIgnoreList, ExtensionMapping, FilePattern, FilePatternSet, PerFileIgnore, - PreviewMode, PythonVersion, RequiredVersion, SerializationFormat, UnsafeFixes, + CompiledPerFileIgnoreList, ExtensionMapping, FilePattern, FilePatternSet, OutputFormat, + PerFileIgnore, PreviewMode, PythonVersion, RequiredVersion, UnsafeFixes, }; use ruff_linter::settings::{LinterSettings, DEFAULT_SELECTORS, DUMMY_VARIABLE_RGX, TASK_TAGS}; use ruff_linter::{ @@ -116,7 +116,7 @@ pub struct Configuration { pub fix: Option, pub fix_only: Option, pub unsafe_fixes: Option, - pub output_format: Option, + pub output_format: Option, pub preview: Option, pub required_version: Option, pub extension: Option, @@ -222,7 +222,7 @@ impl Configuration { unsafe_fixes: self.unsafe_fixes.unwrap_or_default(), output_format: self .output_format - .unwrap_or_else(|| SerializationFormat::default(global_preview.is_enabled())), + .unwrap_or_else(|| OutputFormat::default(global_preview.is_enabled())), show_fixes: self.show_fixes.unwrap_or(false), file_resolver: FileResolverSettings { @@ -429,14 +429,13 @@ impl Configuration { options.indent_width.or(options.tab_size) }; - #[allow(deprecated)] let output_format = { options .output_format .map(|format| match format { - SerializationFormat::Text => { - warn_user_once!(r#"Setting `output_format` to "text" is deprecated. Use "full" or "concise" instead. "text" will be treated as "{}"."#, SerializationFormat::default(options.preview.unwrap_or_default())); - SerializationFormat::default(options.preview.unwrap_or_default()) + OutputFormat::Text => { + warn_user_once!(r#"Setting `output_format` to "text" is deprecated. Use "full" or "concise" instead. "text" will be treated as "{}"."#, OutputFormat::default(options.preview.unwrap_or_default())); + OutputFormat::default(options.preview.unwrap_or_default()) }, other => other }) diff --git a/crates/ruff_workspace/src/options.rs b/crates/ruff_workspace/src/options.rs index 4f26746e32e19..9180371c7bcd2 100644 --- a/crates/ruff_workspace/src/options.rs +++ b/crates/ruff_workspace/src/options.rs @@ -24,7 +24,7 @@ use ruff_linter::rules::{ pycodestyle, pydocstyle, pyflakes, pylint, pyupgrade, }; use ruff_linter::settings::types::{ - IdentifierPattern, PythonVersion, RequiredVersion, SerializationFormat, + IdentifierPattern, OutputFormat, PythonVersion, RequiredVersion, }; use ruff_linter::{warn_user_once, RuleSelector}; use ruff_macros::{CombineOptions, OptionsMetadata}; @@ -86,7 +86,7 @@ pub struct Options { output-format = "grouped" "# )] - pub output_format: Option, + pub output_format: Option, /// Enable fix behavior by-default when running `ruff` (overridden /// by the `--fix` and `--no-fix` command-line flags). diff --git a/crates/ruff_workspace/src/settings.rs b/crates/ruff_workspace/src/settings.rs index a650f93d19742..7631c427f0632 100644 --- a/crates/ruff_workspace/src/settings.rs +++ b/crates/ruff_workspace/src/settings.rs @@ -3,7 +3,7 @@ use ruff_cache::cache_dir; use ruff_formatter::{FormatOptions, IndentStyle, IndentWidth, LineWidth}; use ruff_linter::display_settings; use ruff_linter::settings::types::{ - ExtensionMapping, FilePattern, FilePatternSet, SerializationFormat, UnsafeFixes, + ExtensionMapping, FilePattern, FilePatternSet, OutputFormat, UnsafeFixes, }; use ruff_linter::settings::LinterSettings; use ruff_macros::CacheKey; @@ -28,7 +28,7 @@ pub struct Settings { #[cache_key(ignore)] pub unsafe_fixes: UnsafeFixes, #[cache_key(ignore)] - pub output_format: SerializationFormat, + pub output_format: OutputFormat, #[cache_key(ignore)] pub show_fixes: bool, @@ -44,7 +44,7 @@ impl Default for Settings { cache_dir: cache_dir(project_root), fix: false, fix_only: false, - output_format: SerializationFormat::default(false), + output_format: OutputFormat::default(false), show_fixes: false, unsafe_fixes: UnsafeFixes::default(), linter: LinterSettings::new(project_root), diff --git a/ruff.schema.json b/ruff.schema.json index 6a5eb454fbbbb..5d390e2408019 100644 --- a/ruff.schema.json +++ b/ruff.schema.json @@ -534,7 +534,7 @@ "description": "The style in which violation messages should be formatted: `\"full\"` (shows source),`\"concise\"` (default), `\"grouped\"` (group messages by file), `\"json\"` (machine-readable), `\"junit\"` (machine-readable XML), `\"github\"` (GitHub Actions annotations), `\"gitlab\"` (GitLab CI code quality report), `\"pylint\"` (Pylint text format) or `\"azure\"` (Azure Pipeline logging commands).", "anyOf": [ { - "$ref": "#/definitions/SerializationFormat" + "$ref": "#/definitions/OutputFormat" }, { "type": "null" @@ -2293,6 +2293,24 @@ }, "additionalProperties": false }, + "OutputFormat": { + "type": "string", + "enum": [ + "text", + "concise", + "full", + "json", + "json-lines", + "junit", + "grouped", + "github", + "gitlab", + "pylint", + "rdjson", + "azure", + "sarif" + ] + }, "ParametrizeNameType": { "type": "string", "enum": [ @@ -3931,24 +3949,6 @@ "YTT303" ] }, - "SerializationFormat": { - "type": "string", - "enum": [ - "text", - "concise", - "full", - "json", - "json-lines", - "junit", - "grouped", - "github", - "gitlab", - "pylint", - "rdjson", - "azure", - "sarif" - ] - }, "Strictness": { "oneOf": [ {