Skip to content

Commit 3a1033a

Browse files
committed
debug log when parsing fails during fallback discovery
1 parent c32399c commit 3a1033a

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

crates/ruff_workspace/src/pyproject.rs

+11-1
Original file line numberDiff line numberDiff line change
@@ -201,9 +201,19 @@ pub(super) fn load_options<P: AsRef<Path>>(
201201
/// if the file exists and has `requires-python`.
202202
fn get_fallback_target_version(dir: &Path) -> Option<PythonVersion> {
203203
let pyproject_path = dir.join("pyproject.toml");
204-
let Ok(pyproject) = parse_pyproject_toml(pyproject_path) else {
204+
if !pyproject_path.exists() {
205205
return None;
206+
}
207+
let parsed_pyproject = parse_pyproject_toml(&pyproject_path);
208+
209+
let pyproject = match parsed_pyproject {
210+
Ok(pyproject) => pyproject,
211+
Err(err) => {
212+
debug!("Failed to find fallback `target-version` due to: {}", err);
213+
return None;
214+
}
206215
};
216+
207217
if let Some(project) = pyproject.project {
208218
if let Some(requires_python) = project.requires_python {
209219
return get_minimum_supported_version(&requires_python);

0 commit comments

Comments
 (0)