From 0c110bcecf3b225be403c0be9509c01558a1bc27 Mon Sep 17 00:00:00 2001 From: Charlie Marsh Date: Thu, 1 Sep 2022 09:18:47 -0400 Subject: [PATCH] Add some user-visible logging when pyproject.toml fails to parse --- src/checks.rs | 4 +--- src/pyproject.rs | 10 +++++++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/checks.rs b/src/checks.rs index 89708db494..0ef927f0fb 100644 --- a/src/checks.rs +++ b/src/checks.rs @@ -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 => { diff --git a/src/pyproject.rs b/src/pyproject.rs index ce20ef7092..2c48ef0d5d 100644 --- a/src/pyproject.rs +++ b/src/pyproject.rs @@ -13,16 +13,20 @@ pub fn load_config<'a>(paths: impl IntoIterator) -> 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()),