-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Replace --show-source and --no-show-source with --output_format=<full|concise>
#9687
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
2d0f7ee
80ec848
6bce15a
4a69e52
71e7408
672733c
8ebc7c7
b14603d
f761554
e06a385
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -255,7 +255,6 @@ pub fn check(args: CheckCommand, log_level: LogLevel) -> Result<ExitStatus> { | |
| unsafe_fixes, | ||
| output_format, | ||
| show_fixes, | ||
| show_source, | ||
| .. | ||
| } = pyproject_config.settings; | ||
|
|
||
|
|
@@ -284,9 +283,6 @@ pub fn check(args: CheckCommand, log_level: LogLevel) -> Result<ExitStatus> { | |
| if show_fixes { | ||
| printer_flags |= PrinterFlags::SHOW_FIX_SUMMARY; | ||
| } | ||
| if show_source { | ||
| printer_flags |= PrinterFlags::SHOW_SOURCE; | ||
| } | ||
| if cli.ecosystem_ci { | ||
| warn_user!( | ||
| "The formatting of fixes emitted by this option is a work-in-progress, subject to \ | ||
|
|
@@ -325,9 +321,14 @@ pub fn check(args: CheckCommand, log_level: LogLevel) -> Result<ExitStatus> { | |
| printer_flags, | ||
| ); | ||
|
|
||
| let preview = overrides.preview.unwrap_or_default().is_enabled(); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does this respect
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No that was not deliberate, good catch.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No worries! Was trying to pin down the build failures on #9599 after merging in |
||
|
|
||
| if cli.watch { | ||
| if output_format != SerializationFormat::Text { | ||
| warn_user!("`--output-format text` is always used in watch mode."); | ||
| if output_format != SerializationFormat::default(preview) { | ||
| warn_user!( | ||
| "`--output-format {}` is always used in watch mode.", | ||
| SerializationFormat::default(preview) | ||
| ); | ||
| } | ||
|
|
||
| // Configure the file watcher. | ||
|
|
@@ -353,7 +354,7 @@ pub fn check(args: CheckCommand, log_level: LogLevel) -> Result<ExitStatus> { | |
| fix_mode, | ||
| unsafe_fixes, | ||
| )?; | ||
| printer.write_continuously(&mut writer, &messages)?; | ||
| printer.write_continuously(&mut writer, &messages, preview)?; | ||
|
|
||
| // In watch mode, we may need to re-resolve the configuration. | ||
| // TODO(charlie): Re-compute other derivative values, like the `printer`. | ||
|
|
@@ -386,7 +387,7 @@ pub fn check(args: CheckCommand, log_level: LogLevel) -> Result<ExitStatus> { | |
| fix_mode, | ||
| unsafe_fixes, | ||
| )?; | ||
| printer.write_continuously(&mut writer, &messages)?; | ||
| printer.write_continuously(&mut writer, &messages, preview)?; | ||
| } | ||
| Err(err) => return Err(err.into()), | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,149 @@ | ||
| //! A test suite that ensures deprecated command line options have appropriate warnings / behaviors | ||
|
|
||
| use ruff_linter::settings::types::SerializationFormat; | ||
| use std::process::Command; | ||
|
|
||
| use insta_cmd::{assert_cmd_snapshot, get_cargo_bin}; | ||
|
|
||
| const BIN_NAME: &str = "ruff"; | ||
|
|
||
| const STDIN: &str = "l = 1"; | ||
|
|
||
| fn ruff_check(show_source: Option<bool>, output_format: Option<String>) -> Command { | ||
| let mut cmd = Command::new(get_cargo_bin(BIN_NAME)); | ||
| let output_format = output_format.unwrap_or(format!("{}", SerializationFormat::default(false))); | ||
| cmd.arg("--output-format"); | ||
| cmd.arg(output_format); | ||
| cmd.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###" | ||
| 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=text`. | ||
| warning: `--output-format=text` is deprecated. Use `--output-format=full` or `--output-format=concise` instead. `text` will be treated as `concise`. | ||
| "###); | ||
| } |
Uh oh!
There was an error while loading. Please reload this page.