mirror of
https://github.com/astral-sh/ruff.git
synced 2025-09-29 21:35:58 +00:00
Avoid parsing the root configuration twice (#10625)
This commit is contained in:
parent
068e22d382
commit
376fb71a7f
3 changed files with 37 additions and 30 deletions
|
@ -335,6 +335,12 @@ pub fn python_files_in_path<'a>(
|
|||
// Search for `pyproject.toml` files in all parent directories.
|
||||
let mut resolver = Resolver::new(pyproject_config);
|
||||
let mut seen = FxHashSet::default();
|
||||
|
||||
// Insert the path to the root configuration to avoid parsing the configuration a second time.
|
||||
if let Some(config_path) = &pyproject_config.path {
|
||||
seen.insert(config_path.parent().unwrap());
|
||||
}
|
||||
|
||||
if resolver.is_hierarchical() {
|
||||
for path in &paths {
|
||||
for ancestor in path.ancestors() {
|
||||
|
@ -343,8 +349,12 @@ pub fn python_files_in_path<'a>(
|
|||
let (root, settings) =
|
||||
resolve_scoped_settings(&pyproject, Relativity::Parent, transformer)?;
|
||||
resolver.add(root, settings);
|
||||
// We found the closest configuration.
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
// We already visited this ancestor, we can stop here.
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue