mirror of
https://github.com/astral-sh/ruff.git
synced 2025-10-01 22:31:23 +00:00
Fix issue where output format mode would not change to full
if preview mode was set in configuration file (#9763)
## Summary This was causing build failures for #9599. We were referencing the command line overrides instead of the merged configuration data, hence the issue. ## Test Plan A snapshot test was added.
This commit is contained in:
parent
99eddbd2a0
commit
148b64ead3
2 changed files with 34 additions and 1 deletions
|
@ -321,7 +321,11 @@ 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`
|
||||
// TODO: this should reference the global preview mode once https://github.com/astral-sh/ruff/issues/8232
|
||||
// is resolved.
|
||||
let preview = pyproject_config.settings.linter.preview.is_enabled();
|
||||
|
||||
if cli.watch {
|
||||
if output_format != SerializationFormat::default(preview) {
|
||||
|
|
|
@ -755,6 +755,35 @@ fn full_output_preview() {
|
|||
"###);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn full_output_preview_config() -> Result<()> {
|
||||
let tempdir = TempDir::new()?;
|
||||
let pyproject_toml = tempdir.path().join("pyproject.toml");
|
||||
fs::write(
|
||||
&pyproject_toml,
|
||||
r#"
|
||||
[tool.ruff]
|
||||
preview = true
|
||||
"#,
|
||||
)?;
|
||||
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 -----
|
||||
"###);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn full_output_format() {
|
||||
let mut cmd = RuffCheck::default().output_format("full").build();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue