mirror of
https://github.com/astral-sh/ruff.git
synced 2025-10-01 06:11:21 +00:00
fix: Emit a more useful error if an extend
points at a non-existent ruff.toml file. (#3417)
This commit is contained in:
parent
bd05a8a74d
commit
08ec11a31e
2 changed files with 4 additions and 9 deletions
|
@ -127,7 +127,8 @@ pub fn resolve_configuration(
|
||||||
}
|
}
|
||||||
|
|
||||||
// Resolve the current path.
|
// Resolve the current path.
|
||||||
let options = pyproject::load_options(&path)?;
|
let options = pyproject::load_options(&path)
|
||||||
|
.map_err(|err| anyhow!("Failed to parse `{}`: {}", path.to_string_lossy(), err))?;
|
||||||
let project_root = relativity.resolve(&path);
|
let project_root = relativity.resolve(&path);
|
||||||
let configuration = Configuration::from_options(options, &project_root)?;
|
let configuration = Configuration::from_options(options, &project_root)?;
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
use std::path::{Path, PathBuf};
|
use std::path::{Path, PathBuf};
|
||||||
|
|
||||||
use anyhow::{anyhow, Result};
|
use anyhow::Result;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
use crate::settings::options::Options;
|
use crate::settings::options::Options;
|
||||||
|
@ -113,13 +113,7 @@ pub fn find_user_settings_toml() -> Option<PathBuf> {
|
||||||
/// Load `Options` from a `pyproject.toml` or `ruff.toml` file.
|
/// Load `Options` from a `pyproject.toml` or `ruff.toml` file.
|
||||||
pub fn load_options<P: AsRef<Path>>(path: P) -> Result<Options> {
|
pub fn load_options<P: AsRef<Path>>(path: P) -> Result<Options> {
|
||||||
if path.as_ref().ends_with("pyproject.toml") {
|
if path.as_ref().ends_with("pyproject.toml") {
|
||||||
let pyproject = parse_pyproject_toml(&path).map_err(|err| {
|
let pyproject = parse_pyproject_toml(&path)?;
|
||||||
anyhow!(
|
|
||||||
"Failed to parse `{}`: {}",
|
|
||||||
path.as_ref().to_string_lossy(),
|
|
||||||
err
|
|
||||||
)
|
|
||||||
})?;
|
|
||||||
Ok(pyproject
|
Ok(pyproject
|
||||||
.tool
|
.tool
|
||||||
.and_then(|tool| tool.ruff)
|
.and_then(|tool| tool.ruff)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue