mirror of
https://github.com/astral-sh/ruff.git
synced 2025-08-03 18:28:24 +00:00
ruff server
searches for configuration in parent directories (#11537)
## Summary Fixes #11506. `RuffSettingsIndex::new` now searches for configuration files in parent directories. ## Test Plan I confirmed that the original test case described in the issue worked as expected.
This commit is contained in:
parent
0eef834e89
commit
627d230688
1 changed files with 30 additions and 0 deletions
|
@ -82,6 +82,32 @@ impl RuffSettingsIndex {
|
|||
pub(super) fn new(root: &Path, editor_settings: &ResolvedEditorSettings) -> Self {
|
||||
let mut index = BTreeMap::default();
|
||||
|
||||
// Add any settings from above the workspace root.
|
||||
for directory in root.ancestors() {
|
||||
if let Some(pyproject) = settings_toml(directory).ok().flatten() {
|
||||
if index.contains_key(&pyproject) {
|
||||
continue;
|
||||
}
|
||||
|
||||
let Ok(settings) = ruff_workspace::resolver::resolve_root_settings(
|
||||
&pyproject,
|
||||
Relativity::Parent,
|
||||
&EditorConfigurationTransformer(editor_settings, root),
|
||||
) else {
|
||||
continue;
|
||||
};
|
||||
index.insert(
|
||||
directory.to_path_buf(),
|
||||
Arc::new(RuffSettings {
|
||||
linter: settings.linter,
|
||||
formatter: settings.formatter,
|
||||
}),
|
||||
);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Add any settings within the workspace itself.
|
||||
for directory in WalkDir::new(root)
|
||||
.into_iter()
|
||||
.filter_map(Result::ok)
|
||||
|
@ -89,6 +115,10 @@ impl RuffSettingsIndex {
|
|||
.map(DirEntry::into_path)
|
||||
{
|
||||
if let Some(pyproject) = settings_toml(&directory).ok().flatten() {
|
||||
if index.contains_key(&pyproject) {
|
||||
continue;
|
||||
}
|
||||
|
||||
let Ok(settings) = ruff_workspace::resolver::resolve_root_settings(
|
||||
&pyproject,
|
||||
Relativity::Parent,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue