diff --git a/crates/pixi-build/src/bin/pixi-build-python/python.rs b/crates/pixi-build/src/bin/pixi-build-python/python.rs index 204b990..5bc66a9 100644 --- a/crates/pixi-build/src/bin/pixi-build-python/python.rs +++ b/crates/pixi-build/src/bin/pixi-build-python/python.rs @@ -406,38 +406,35 @@ fn input_globs() -> Vec { /// Returns the entry points from pyproject.toml scripts table fn get_entry_points(toml_document: &TomlDocument) -> miette::Result>> { - let scripts = toml_document.get_nested_table("project.scripts").ok(); + let Ok(scripts) = toml_document.get_nested_table("project.scripts") else { + return Ok(None); + }; + // all the entry points are in the form of a table - if let Some(scripts) = scripts { - let entry_points = scripts - .get_values() - .iter() - .map(|(k, v)| { - // Ensure the key vector has exactly one element - let key = k - .first() - .ok_or_else(|| miette::miette!("entry points should have a key"))?; - - if k.len() > 1 { - return Err(miette::miette!("entry points should be a single key")); - } + let entry_points = scripts + .get_values() + .iter() + .map(|(k, v)| { + // Ensure the key vector has exactly one element + let key = k + .first() + .ok_or_else(|| miette::miette!("entry points should have a key"))?; + + if k.len() > 1 { + return Err(miette::miette!("entry points should be a single key")); + } - let value = v - .as_str() - .ok_or_else(|| miette::miette!("entry point value {v} should be a string"))?; + let value = v + .as_str() + .ok_or_else(|| miette::miette!("entry point value {v} should be a string"))?; - // format it as a script = some_module:some_function - let entry_point_str = format!("{} = {}", key, value); - EntryPoint::from_str(&entry_point_str).map_err(|e| { - miette::miette!("failed to parse entry point {}: {}", entry_point_str, e) - }) - }) - .collect::, _>>()?; - - return Ok(Some(entry_points)); - } + // format it as a script = some_module:some_function + let entry_point_str = format!("{} = {}", key, value); + EntryPoint::from_str(&entry_point_str).map_err(|e| miette::miette!("{e}")) + }) + .collect::, _>>()?; - Ok(None) + Ok(Some(entry_points)) } #[async_trait::async_trait]