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

ruff server searches for configuration in parent directories #11537

Merged
merged 3 commits into from
May 26, 2024
Merged
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
8 changes: 6 additions & 2 deletions crates/ruff_server/src/session/index/ruff_settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use ruff_linter::{
};
use ruff_workspace::{
configuration::{Configuration, FormatConfiguration, LintConfiguration, RuleSelection},
pyproject::{find_user_settings_toml, settings_toml},
pyproject::{find_settings_toml, find_user_settings_toml},
resolver::{ConfigurationTransformer, Relativity},
};
use std::{
Expand Down Expand Up @@ -88,7 +88,11 @@ impl RuffSettingsIndex {
.filter(|entry| entry.file_type().is_dir())
.map(DirEntry::into_path)
{
if let Some(pyproject) = settings_toml(&directory).ok().flatten() {
if let Some(pyproject) = find_settings_toml(&directory).ok().flatten() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should only do this once, for the root path.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's no need to search in parent directories for every directory, since there's at most one pyproject above the root path.

if index.contains_key(&pyproject) {
continue;
}

let Ok(settings) = ruff_workspace::resolver::resolve_root_settings(
&pyproject,
Relativity::Parent,
Expand Down
Loading