mirror of
https://github.com/astral-sh/uv.git
synced 2025-11-01 20:31:12 +00:00
Remove some anyhow usages (#3962)
This commit is contained in:
parent
a70e33d947
commit
11324646cb
11 changed files with 19 additions and 15 deletions
|
|
@ -36,7 +36,6 @@ use std::borrow::Cow;
|
||||||
use std::path::{Path, PathBuf};
|
use std::path::{Path, PathBuf};
|
||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
|
|
||||||
use anyhow::Result;
|
|
||||||
use url::Url;
|
use url::Url;
|
||||||
|
|
||||||
use distribution_filename::WheelFilename;
|
use distribution_filename::WheelFilename;
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,5 @@
|
||||||
use std::borrow::Cow;
|
use std::borrow::Cow;
|
||||||
|
|
||||||
use anyhow::Result;
|
|
||||||
|
|
||||||
use pep508_rs::VerbatimUrl;
|
use pep508_rs::VerbatimUrl;
|
||||||
use uv_normalize::PackageName;
|
use uv_normalize::PackageName;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -8,9 +8,10 @@ use hyper::service::service_fn;
|
||||||
use hyper::{Request, Response};
|
use hyper::{Request, Response};
|
||||||
use hyper_util::rt::TokioIo;
|
use hyper_util::rt::TokioIo;
|
||||||
use insta::{assert_json_snapshot, assert_snapshot, with_settings};
|
use insta::{assert_json_snapshot, assert_snapshot, with_settings};
|
||||||
|
use tokio::net::TcpListener;
|
||||||
|
|
||||||
use pep508_rs::{MarkerEnvironment, MarkerEnvironmentBuilder};
|
use pep508_rs::{MarkerEnvironment, MarkerEnvironmentBuilder};
|
||||||
use platform_tags::{Arch, Os, Platform};
|
use platform_tags::{Arch, Os, Platform};
|
||||||
use tokio::net::TcpListener;
|
|
||||||
use uv_cache::Cache;
|
use uv_cache::Cache;
|
||||||
use uv_client::LineHaul;
|
use uv_client::LineHaul;
|
||||||
use uv_client::RegistryClientBuilder;
|
use uv_client::RegistryClientBuilder;
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,6 @@ use std::path::{Path, PathBuf};
|
||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
use anyhow::Result;
|
|
||||||
use fs_err::tokio as fs;
|
use fs_err::tokio as fs;
|
||||||
use futures::{FutureExt, TryStreamExt};
|
use futures::{FutureExt, TryStreamExt};
|
||||||
use reqwest::Response;
|
use reqwest::Response;
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
use anyhow::Result;
|
|
||||||
use tracing::debug;
|
use tracing::debug;
|
||||||
|
|
||||||
use cache_key::RepositoryUrl;
|
use cache_key::RepositoryUrl;
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,3 @@
|
||||||
use anyhow::Result;
|
|
||||||
|
|
||||||
use distribution_types::InstalledDist;
|
use distribution_types::InstalledDist;
|
||||||
|
|
||||||
/// Uninstall a package from the specified Python environment.
|
/// Uninstall a package from the specified Python environment.
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,6 @@ use std::path::Path;
|
||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
use anyhow::Result;
|
|
||||||
use configparser::ini::Ini;
|
use configparser::ini::Ini;
|
||||||
use futures::{stream::FuturesOrdered, TryStreamExt};
|
use futures::{stream::FuturesOrdered, TryStreamExt};
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
|
|
@ -22,6 +21,18 @@ use uv_normalize::PackageName;
|
||||||
use uv_resolver::{InMemoryIndex, MetadataResponse};
|
use uv_resolver::{InMemoryIndex, MetadataResponse};
|
||||||
use uv_types::{BuildContext, HashStrategy};
|
use uv_types::{BuildContext, HashStrategy};
|
||||||
|
|
||||||
|
#[derive(Debug, thiserror::Error)]
|
||||||
|
pub enum NamedRequirementsError {
|
||||||
|
#[error(transparent)]
|
||||||
|
Distribution(#[from] uv_distribution::Error),
|
||||||
|
|
||||||
|
#[error(transparent)]
|
||||||
|
DistributionTypes(#[from] distribution_types::Error),
|
||||||
|
|
||||||
|
#[error(transparent)]
|
||||||
|
WheelFilename(#[from] distribution_filename::WheelFilenameError),
|
||||||
|
}
|
||||||
|
|
||||||
/// Like [`RequirementsSpecification`], but with concrete names for all requirements.
|
/// Like [`RequirementsSpecification`], but with concrete names for all requirements.
|
||||||
pub struct NamedRequirementsResolver<'a, Context: BuildContext> {
|
pub struct NamedRequirementsResolver<'a, Context: BuildContext> {
|
||||||
/// The requirements for the project.
|
/// The requirements for the project.
|
||||||
|
|
@ -60,7 +71,7 @@ impl<'a, Context: BuildContext> NamedRequirementsResolver<'a, Context> {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Resolve any unnamed requirements in the specification.
|
/// Resolve any unnamed requirements in the specification.
|
||||||
pub async fn resolve(self) -> Result<Vec<Requirement>> {
|
pub async fn resolve(self) -> Result<Vec<Requirement>, NamedRequirementsError> {
|
||||||
let Self {
|
let Self {
|
||||||
requirements,
|
requirements,
|
||||||
hasher,
|
hasher,
|
||||||
|
|
@ -88,7 +99,7 @@ impl<'a, Context: BuildContext> NamedRequirementsResolver<'a, Context> {
|
||||||
hasher: &HashStrategy,
|
hasher: &HashStrategy,
|
||||||
index: &InMemoryIndex,
|
index: &InMemoryIndex,
|
||||||
database: &DistributionDatabase<'a, Context>,
|
database: &DistributionDatabase<'a, Context>,
|
||||||
) -> Result<pep508_rs::Requirement<VerbatimParsedUrl>> {
|
) -> Result<pep508_rs::Requirement<VerbatimParsedUrl>, NamedRequirementsError> {
|
||||||
// If the requirement is a wheel, extract the package name from the wheel filename.
|
// If the requirement is a wheel, extract the package name from the wheel filename.
|
||||||
//
|
//
|
||||||
// Ex) `anyio-4.3.0-py3-none-any.whl`
|
// Ex) `anyio-4.3.0-py3-none-any.whl`
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,3 @@
|
||||||
use anyhow::Result;
|
|
||||||
use pubgrub::range::Range;
|
use pubgrub::range::Range;
|
||||||
|
|
||||||
use pep440_rs::{Operator, PreRelease, Version, VersionSpecifier};
|
use pep440_rs::{Operator, PreRelease, Version, VersionSpecifier};
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,6 @@ use std::ops::Deref;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use std::thread;
|
use std::thread;
|
||||||
|
|
||||||
use anyhow::Result;
|
|
||||||
use dashmap::DashMap;
|
use dashmap::DashMap;
|
||||||
use futures::{FutureExt, StreamExt, TryFutureExt};
|
use futures::{FutureExt, StreamExt, TryFutureExt};
|
||||||
use itertools::Itertools;
|
use itertools::Itertools;
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,5 @@
|
||||||
use std::future::Future;
|
use std::future::Future;
|
||||||
|
|
||||||
use anyhow::Result;
|
|
||||||
|
|
||||||
use distribution_types::{Dist, IndexLocations};
|
use distribution_types::{Dist, IndexLocations};
|
||||||
use platform_tags::Tags;
|
use platform_tags::Tags;
|
||||||
use uv_configuration::{NoBinary, NoBuild};
|
use uv_configuration::{NoBinary, NoBuild};
|
||||||
|
|
|
||||||
|
|
@ -725,6 +725,9 @@ pub(crate) enum Error {
|
||||||
#[error(transparent)]
|
#[error(transparent)]
|
||||||
Lookahead(#[from] uv_requirements::LookaheadError),
|
Lookahead(#[from] uv_requirements::LookaheadError),
|
||||||
|
|
||||||
|
#[error(transparent)]
|
||||||
|
Named(#[from] uv_requirements::NamedRequirementsError),
|
||||||
|
|
||||||
#[error(transparent)]
|
#[error(transparent)]
|
||||||
Anyhow(#[from] anyhow::Error),
|
Anyhow(#[from] anyhow::Error),
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue