diff --git a/crates/ruff_cli/tests/lint.rs b/crates/ruff_cli/tests/lint.rs index f36f612ba89199..5dfbd56f83c559 100644 --- a/crates/ruff_cli/tests/lint.rs +++ b/crates/ruff_cli/tests/lint.rs @@ -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(()) +} diff --git a/crates/ruff_workspace/src/resolver.rs b/crates/ruff_workspace/src/resolver.rs index fc12feaad3ace0..93df74b1e2aad9 100644 --- a/crates/ruff_workspace/src/resolver.rs +++ b/crates/ruff_workspace/src/resolver.rs @@ -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; } } }