Skip to content

Commit a7eb5af

Browse files
committed
fix: Emit a more useful error if an extend points at a non-existent ruff.toml file.
1 parent bd05a8a commit a7eb5af

File tree

2 files changed

+4
-9
lines changed

2 files changed

+4
-9
lines changed

crates/ruff/src/resolver.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,8 @@ pub fn resolve_configuration(
127127
}
128128

129129
// Resolve the current path.
130-
let options = pyproject::load_options(&path)?;
130+
let options = pyproject::load_options(&path)
131+
.map_err(|err| anyhow!("Failed to parse `{}`: {}", path.to_string_lossy(), err))?;
131132
let project_root = relativity.resolve(&path);
132133
let configuration = Configuration::from_options(options, &project_root)?;
133134

crates/ruff/src/settings/pyproject.rs

+2-8
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
33
use std::path::{Path, PathBuf};
44

5-
use anyhow::{anyhow, Result};
5+
use anyhow::Result;
66
use serde::{Deserialize, Serialize};
77

88
use crate::settings::options::Options;
@@ -113,13 +113,7 @@ pub fn find_user_settings_toml() -> Option<PathBuf> {
113113
/// Load `Options` from a `pyproject.toml` or `ruff.toml` file.
114114
pub fn load_options<P: AsRef<Path>>(path: P) -> Result<Options> {
115115
if path.as_ref().ends_with("pyproject.toml") {
116-
let pyproject = parse_pyproject_toml(&path).map_err(|err| {
117-
anyhow!(
118-
"Failed to parse `{}`: {}",
119-
path.as_ref().to_string_lossy(),
120-
err
121-
)
122-
})?;
116+
let pyproject = parse_pyproject_toml(&path)?;
123117
Ok(pyproject
124118
.tool
125119
.and_then(|tool| tool.ruff)

0 commit comments

Comments
 (0)