Check if toml file is parsed, program crashes otherwise without

information. If not parsed, use default
This commit is contained in:
Patrick Haller 2022-09-01 14:44:39 +02:00
parent 64df4eb311
commit 0dc79db0c8
1 changed files with 11 additions and 7 deletions

View File

@ -13,13 +13,17 @@ pub fn load_config<'a>(paths: impl IntoIterator<Item = &'a Path>) -> Result<(Pat
match find_project_root(paths) {
Some(project_root) => match find_pyproject_toml(&project_root) {
Some(path) => {
debug!("Found pyproject.toml at: {}", path.to_string_lossy());
let pyproject = parse_pyproject_toml(&path)?;
let config = pyproject
.tool
.and_then(|tool| tool.ruff)
.unwrap_or_default();
Ok((project_root, config))
match parse_pyproject_toml(&path) {
Ok(pyproject) => {
debug!("Found pyproject.toml at: {}", path.to_string_lossy());
let config = pyproject
.tool
.and_then(|tool| tool.ruff)
.unwrap_or_default();
Ok((project_root, config))
},
Err(_) => Ok(Default::default())
}
}
None => Ok(Default::default()),
},