Skip to content
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

Fix issue where output format mode would not change to full if preview mode was set in configuration file #9763

Merged
merged 3 commits into from
Feb 1, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion crates/ruff/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,9 @@ pub fn check(args: CheckCommand, log_level: LogLevel) -> Result<ExitStatus> {
printer_flags,
);

let preview = overrides.preview.unwrap_or_default().is_enabled();
// the settings should already be combined with the CLI overrides at this point
// TODO(jane): let's make this `PreviewMode`
let preview = pyproject_config.settings.linter.preview.is_enabled();
snowsignal marked this conversation as resolved.
Show resolved Hide resolved

if cli.watch {
if output_format != SerializationFormat::default(preview) {
Expand Down
29 changes: 29 additions & 0 deletions crates/ruff/tests/integration_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -755,6 +755,35 @@ fn full_output_preview() {
"###);
}

#[test]
fn full_output_preview_config() {
let tempdir = TempDir::new().unwrap();
let pyproject_toml = tempdir.path().join("pyproject.toml");
fs::write(
&pyproject_toml,
r#"
[tool.ruff]
preview = true
"#,
)
.unwrap();
let mut cmd = RuffCheck::default().config(&pyproject_toml).build();
assert_cmd_snapshot!(cmd.pass_stdin("l = 1"), @r###"
success: false
exit_code: 1
----- stdout -----
-:1:1: E741 Ambiguous variable name: `l`
|
1 | l = 1
| ^ E741
|

Found 1 error.

----- stderr -----
"###);
snowsignal marked this conversation as resolved.
Show resolved Hide resolved
}

#[test]
fn full_output_format() {
let mut cmd = RuffCheck::default().output_format("full").build();
Expand Down
Loading