Skip to content

Commit 730bae4

Browse files
committed
better error message when an inherited config path doesn't exist
1 parent 1ef0f61 commit 730bae4

File tree

1 file changed

+17
-7
lines changed

1 file changed

+17
-7
lines changed

crates/ruff_workspace/src/resolver.rs

+17-7
Original file line numberDiff line numberDiff line change
@@ -306,24 +306,34 @@ pub fn resolve_configuration(
306306
) -> Result<Configuration> {
307307
let mut seen = FxHashSet::default();
308308
let mut stack = vec![];
309-
let mut next = Some(fs::normalize_path(pyproject));
310-
while let Some(path) = next {
309+
let mut next = Some((fs::normalize_path(pyproject), None::<PathBuf>));
310+
while let Some((path, inherited_by)) = next {
311311
if seen.contains(&path) {
312312
bail!("Circular dependency detected in pyproject.toml");
313313
}
314314

315315
// Resolve the current path.
316-
let options = pyproject::load_options(&path)?;
316+
let options = pyproject::load_options(&path).map_err(|err| match inherited_by {
317+
Some(f) => err.context(format!(
318+
"Failed to load path {} inherited by {}",
319+
path.display(),
320+
f.display(),
321+
)),
322+
None => err,
323+
})?;
317324

318325
let project_root = relativity.resolve(&path);
319326
let configuration = Configuration::from_options(options, Some(&path), project_root)?;
320327

321328
// If extending, continue to collect.
322329
next = configuration.extend.as_ref().map(|extend| {
323-
fs::normalize_path_to(
324-
extend,
325-
path.parent()
326-
.expect("Expected pyproject.toml file to be in parent directory"),
330+
(
331+
fs::normalize_path_to(
332+
extend,
333+
path.parent()
334+
.expect("Expected pyproject.toml file to be in parent directory"),
335+
),
336+
Some(path.clone()),
327337
)
328338
});
329339

0 commit comments

Comments
 (0)