mirror of
https://github.com/astral-sh/ruff.git
synced 2025-08-04 18:58:04 +00:00
Stop at the first resolved parent configuration (#8864)
This commit is contained in:
parent
6435e4e4aa
commit
cddc696896
2 changed files with 42 additions and 0 deletions
|
@ -396,3 +396,43 @@ if __name__ == "__main__":
|
|||
"###);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Regression test for [#8858](https://github.com/astral-sh/ruff/issues/8858)
|
||||
#[test]
|
||||
fn parent_configuration_override() -> Result<()> {
|
||||
let tempdir = TempDir::new()?;
|
||||
let root_ruff = tempdir.path().join("ruff.toml");
|
||||
fs::write(
|
||||
root_ruff,
|
||||
r#"
|
||||
[lint]
|
||||
select = ["ALL"]
|
||||
"#,
|
||||
)?;
|
||||
|
||||
let sub_dir = tempdir.path().join("subdirectory");
|
||||
fs::create_dir(&sub_dir)?;
|
||||
|
||||
let subdirectory_ruff = sub_dir.join("ruff.toml");
|
||||
fs::write(
|
||||
subdirectory_ruff,
|
||||
r#"
|
||||
[lint]
|
||||
ignore = ["D203", "D212"]
|
||||
"#,
|
||||
)?;
|
||||
|
||||
assert_cmd_snapshot!(Command::new(get_cargo_bin(BIN_NAME))
|
||||
.current_dir(sub_dir)
|
||||
.arg("check")
|
||||
.args(STDIN_BASE_OPTIONS)
|
||||
, @r###"
|
||||
success: true
|
||||
exit_code: 0
|
||||
----- stdout -----
|
||||
|
||||
----- stderr -----
|
||||
warning: No Python files found under the given path(s)
|
||||
"###);
|
||||
Ok(())
|
||||
}
|
||||
|
|
|
@ -294,6 +294,7 @@ pub fn python_files_in_path(
|
|||
let (root, settings) =
|
||||
resolve_scoped_settings(&pyproject, Relativity::Parent, transformer)?;
|
||||
resolver.add(root, settings);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -494,6 +495,7 @@ pub fn python_file_at_path(
|
|||
let (root, settings) =
|
||||
resolve_scoped_settings(&pyproject, Relativity::Parent, transformer)?;
|
||||
resolver.add(root, settings);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue