From c354da6a7ccd5e89dc3e49d18c43a12c8d52441d Mon Sep 17 00:00:00 2001 From: konstin Date: Fri, 25 Jul 2025 19:56:25 +0200 Subject: [PATCH] Get rid of anyhow in the resolver --- Cargo.lock | 1 - .../src/{dist_or_variant_filename.rs => index_entry.rs} | 0 crates/uv-distribution-types/src/lib.rs | 4 ++-- crates/uv-resolver/Cargo.toml | 2 -- crates/uv-resolver/src/error.rs | 2 +- crates/uv-resolver/src/lib.rs | 2 +- crates/uv-resolver/src/resolver/mod.rs | 2 +- crates/uv-resolver/src/resolver/provider.rs | 7 ++++--- 8 files changed, 9 insertions(+), 11 deletions(-) rename crates/uv-distribution-types/src/{dist_or_variant_filename.rs => index_entry.rs} (100%) diff --git a/Cargo.lock b/Cargo.lock index 5294a72fe..6f50888c0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5791,7 +5791,6 @@ dependencies = [ name = "uv-resolver" version = "0.0.1" dependencies = [ - "anyhow", "arcstr", "clap", "dashmap", diff --git a/crates/uv-distribution-types/src/dist_or_variant_filename.rs b/crates/uv-distribution-types/src/index_entry.rs similarity index 100% rename from crates/uv-distribution-types/src/dist_or_variant_filename.rs rename to crates/uv-distribution-types/src/index_entry.rs diff --git a/crates/uv-distribution-types/src/lib.rs b/crates/uv-distribution-types/src/lib.rs index d8d8ea675..0c6630714 100644 --- a/crates/uv-distribution-types/src/lib.rs +++ b/crates/uv-distribution-types/src/lib.rs @@ -59,12 +59,12 @@ pub use crate::cached::*; pub use crate::dependency_metadata::*; pub use crate::diagnostic::*; pub use crate::dist_error::*; -pub use crate::dist_or_variant_filename::*; pub use crate::error::*; pub use crate::file::*; pub use crate::hash::*; pub use crate::id::*; pub use crate::index::*; +pub use crate::index_entry::*; pub use crate::index_name::*; pub use crate::index_url::*; pub use crate::installed::*; @@ -89,12 +89,12 @@ mod cached; mod dependency_metadata; mod diagnostic; mod dist_error; -mod dist_or_variant_filename; mod error; mod file; mod hash; mod id; mod index; +mod index_entry; mod index_name; mod index_url; mod installed; diff --git a/crates/uv-resolver/Cargo.toml b/crates/uv-resolver/Cargo.toml index 1d5ae90f4..1e419a2f7 100644 --- a/crates/uv-resolver/Cargo.toml +++ b/crates/uv-resolver/Cargo.toml @@ -43,8 +43,6 @@ uv-variants = { workspace = true } uv-warnings = { workspace = true } uv-workspace = { workspace = true } -# TODO(konsti): no anyhow plz rlly -anyhow = { workspace = true } arcstr = { workspace = true } clap = { workspace = true, features = ["derive"], optional = true } dashmap = { workspace = true } diff --git a/crates/uv-resolver/src/error.rs b/crates/uv-resolver/src/error.rs index b09972019..ed26e54ef 100644 --- a/crates/uv-resolver/src/error.rs +++ b/crates/uv-resolver/src/error.rs @@ -48,7 +48,7 @@ pub enum ResolveError { ), #[error(transparent)] - VariantFrontend(anyhow::Error), + VariantFrontend(uv_distribution::Error), #[error(transparent)] Client(#[from] uv_client::Error), diff --git a/crates/uv-resolver/src/lib.rs b/crates/uv-resolver/src/lib.rs index e91df3a7e..cd10db256 100644 --- a/crates/uv-resolver/src/lib.rs +++ b/crates/uv-resolver/src/lib.rs @@ -21,7 +21,7 @@ pub use resolution_mode::ResolutionMode; pub use resolver::{ BuildId, DefaultResolverProvider, DerivationChainBuilder, InMemoryIndex, MetadataResponse, PackageVersionsResult, Reporter as ResolverReporter, Resolver, ResolverEnvironment, - ResolverProvider, VersionsResponse, WheelMetadataResult, + ResolverProvider, VariantProviderResult, VersionsResponse, WheelMetadataResult, }; pub use universal_marker::{ConflictMarker, UniversalMarker}; pub use version_map::VersionMap; diff --git a/crates/uv-resolver/src/resolver/mod.rs b/crates/uv-resolver/src/resolver/mod.rs index 0dfa9b0c6..384088614 100644 --- a/crates/uv-resolver/src/resolver/mod.rs +++ b/crates/uv-resolver/src/resolver/mod.rs @@ -71,7 +71,7 @@ pub use crate::resolver::index::InMemoryIndex; use crate::resolver::indexes::Indexes; pub use crate::resolver::provider::{ DefaultResolverProvider, MetadataResponse, PackageVersionsResult, ResolverProvider, - VersionsResponse, WheelMetadataResult, + VariantProviderResult, VersionsResponse, WheelMetadataResult, }; pub use crate::resolver::reporter::{BuildId, Reporter}; use crate::resolver::system::SystemDependency; diff --git a/crates/uv-resolver/src/resolver/provider.rs b/crates/uv-resolver/src/resolver/provider.rs index 0150ed79b..77a7e818b 100644 --- a/crates/uv-resolver/src/resolver/provider.rs +++ b/crates/uv-resolver/src/resolver/provider.rs @@ -20,6 +20,7 @@ use crate::yanks::AllowedYanks; pub type PackageVersionsResult = Result; pub type WheelMetadataResult = Result; +pub type VariantProviderResult = Result; /// The response when requesting versions for a package #[derive(Debug)] @@ -104,7 +105,7 @@ pub trait ResolverProvider { fn fetch_and_query_variants<'io>( &'io self, variants_json: &'io RegistryVariantsJson, - ) -> impl Future> + 'io; + ) -> impl Future + 'io; /// Set the [`Reporter`] to use for this installer. #[must_use] @@ -312,8 +313,8 @@ impl ResolverProvider for DefaultResolverProvider<'_, Con async fn fetch_and_query_variants<'io>( &'io self, variants_json: &'io RegistryVariantsJson, - ) -> anyhow::Result { - Ok(self.fetcher.fetch_and_query_variants(variants_json).await?) + ) -> VariantProviderResult { + self.fetcher.fetch_and_query_variants(variants_json).await } /// Set the [`Reporter`] to use for this installer.