diff --git a/rye/src/config.rs b/rye/src/config.rs index 2d151d9966..dd173268d6 100644 --- a/rye/src/config.rs +++ b/rye/src/config.rs @@ -232,7 +232,8 @@ impl Config { if let Some(sources) = self.doc.get("sources").map(|x| toml::iter_tables(x)) { for source in sources { let source = source.context("invalid value for source in config.toml")?; - let source_ref = SourceRef::from_toml_table(source)?; + let source_ref = SourceRef::from_toml_table(source) + .context("invalid source definition in config.toml")?; if source_ref.name == "default" { need_default = false; } diff --git a/rye/src/pyproject.rs b/rye/src/pyproject.rs index bf32b073f4..0c31cdedaa 100644 --- a/rye/src/pyproject.rs +++ b/rye/src/pyproject.rs @@ -152,12 +152,12 @@ impl SourceRef { .get("name") .and_then(|x| x.as_str()) .map(|x| x.to_string()) - .ok_or_else(|| anyhow!("expected name"))?; + .ok_or_else(|| anyhow!("expected source.name"))?; let url = source .get("url") .and_then(|x| x.as_str()) .map(|x| x.to_string()) - .ok_or_else(|| anyhow!("expected url"))?; + .ok_or_else(|| anyhow!("expected source.url"))?; let verify_ssl = source .get("verify_ssl") .and_then(|x| x.as_bool()) @@ -174,7 +174,7 @@ impl SourceRef { .get("type") .and_then(|x| x.as_str()) .map_or(Ok(SourceRefType::Index), |x| x.parse::()) - .context("invalid value for type")?; + .context("invalid value for source.type")?; Ok(SourceRef { name, url, @@ -1252,7 +1252,8 @@ fn get_sources(doc: &DocumentMut) -> Result, Error> { { for source in sources { let source = source.context("invalid value for pyproject.toml's tool.rye.sources")?; - let source_ref = SourceRef::from_toml_table(source)?; + let source_ref = SourceRef::from_toml_table(source) + .context("invalid source definition in pyproject.toml")?; rv.push(source_ref); } } @@ -1299,6 +1300,7 @@ fn get_project_metadata(path: &Path) -> Result { } serde_json::from_slice(&metadata.stdout).map_err(Into::into) } + /// Represents expanded sources. #[derive(Debug, Clone, Serialize)] pub struct ExpandedSources {