From 83067c180248a1fb9bbae33b8579e2d37fef0e47 Mon Sep 17 00:00:00 2001 From: Charlie Marsh Date: Thu, 13 Jun 2024 21:15:53 -0700 Subject: [PATCH] Reduce some `anyhow` usages (#4323) --- crates/uv-resolver/src/lock.rs | 9 ++++----- crates/uv-resolver/src/resolution/graph.rs | 4 ++-- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/crates/uv-resolver/src/lock.rs b/crates/uv-resolver/src/lock.rs index a9edb6bb3..02d961006 100644 --- a/crates/uv-resolver/src/lock.rs +++ b/crates/uv-resolver/src/lock.rs @@ -8,7 +8,6 @@ use std::fmt::{Debug, Display}; use std::path::{Path, PathBuf}; use std::str::FromStr; -use anyhow::Result; use either::Either; use petgraph::visit::EdgeRef; use rustc_hash::FxHashMap; @@ -259,7 +258,7 @@ impl From for LockWire { impl Lock { /// Returns the TOML representation of this lock file. - pub fn to_toml(&self) -> Result { + pub fn to_toml(&self) -> anyhow::Result { // We construct a TOML document manually instead of going through Serde to enable // the use of inline tables. let mut doc = toml_edit::DocumentMut::new(); @@ -332,7 +331,7 @@ impl Lock { Ok(table) }) - .collect::>()?; + .collect::>()?; table.insert("wheels", value(wheels)); } @@ -1237,7 +1236,7 @@ impl SourceDist { impl SourceDist { /// Returns the TOML representation of this source distribution. - fn to_toml(&self) -> Result { + fn to_toml(&self) -> anyhow::Result { let mut table = InlineTable::new(); match &self { SourceDist::Url { url, .. } => { @@ -1589,7 +1588,7 @@ struct WheelWire { impl Wheel { /// Returns the TOML representation of this wheel. - fn to_toml(&self) -> Result { + fn to_toml(&self) -> anyhow::Result { let mut table = InlineTable::new(); table.insert("url", Value::from(self.url.to_string())); if let Some(ref hash) = self.hash { diff --git a/crates/uv-resolver/src/resolution/graph.rs b/crates/uv-resolver/src/resolution/graph.rs index 6f2319ba5..2cf006e84 100644 --- a/crates/uv-resolver/src/resolution/graph.rs +++ b/crates/uv-resolver/src/resolution/graph.rs @@ -53,7 +53,7 @@ impl ResolutionGraph { git: &GitResolver, python: &PythonRequirement, resolution: Resolution, - ) -> anyhow::Result { + ) -> Result { let mut petgraph: Graph, Directed> = Graph::with_capacity(resolution.packages.len(), resolution.packages.len()); let mut inverse: FxHashMap> = FxHashMap::with_capacity_and_hasher( @@ -331,7 +331,7 @@ impl ResolutionGraph { manifest: &Manifest, index: &InMemoryIndex, marker_env: &MarkerEnvironment, - ) -> anyhow::Result> { + ) -> Result> { use pep508_rs::{ MarkerExpression, MarkerOperator, MarkerTree, MarkerValueString, MarkerValueVersion, };