Add some user-visible logging when pyproject.toml fails to parse

This commit is contained in:
Charlie Marsh 2022-09-01 09:18:47 -04:00
parent 9bf8a0d0f1
commit 0c110bcecf
2 changed files with 8 additions and 6 deletions

View File

@ -130,9 +130,7 @@ impl CheckKind {
CheckKind::FStringMissingPlaceholders => {
"f-string without any placeholders".to_string()
}
CheckKind::IfTuple => {
"If test is a tuple, which is always `True`".to_string()
}
CheckKind::IfTuple => "If test is a tuple, which is always `True`".to_string(),
CheckKind::ImportStarUsage => "Unable to detect undefined names".to_string(),
CheckKind::LineTooLong => "Line too long".to_string(),
CheckKind::RaiseNotImplemented => {

View File

@ -13,16 +13,20 @@ 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());
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())
}
Err(e) => {
println!("Failed to load pyproject.toml: {:?}", e);
println!("Falling back to default configuration...");
Ok(Default::default())
}
}
}
None => Ok(Default::default()),