Remove unnecessary wrapping

This commit is contained in:
konstin 2025-05-08 15:06:07 +02:00
parent f99fc82b4a
commit c309d3351c
48 changed files with 64 additions and 63 deletions

View file

@ -0,0 +1,2 @@
pub use anyhow;
pub use traversable_derive::TraversableError;

View file

@ -26,7 +26,7 @@ use crate::{BuildBackendSettings, Error};
/// By default, we ignore generated python files.
pub(crate) const DEFAULT_EXCLUDES: &[&str] = &["__pycache__", "*.pyc", "*.pyo"];
#[derive(Debug, Error)]
#[derive(Debug, Error, traversable_error::TraversableError)]
pub enum ValidationError {
/// The spec isn't clear about what the values in that field would be, and we only support the
/// default value (UTF-8).

View file

@ -54,7 +54,7 @@ static TORCH_NOT_FOUND_RE: LazyLock<Regex> =
static DISTUTILS_NOT_FOUND_RE: LazyLock<Regex> =
LazyLock::new(|| Regex::new(r"ModuleNotFoundError: No module named 'distutils'").unwrap());
#[derive(Error, Debug)]
#[derive(Error, traversable_error::TraversableError, Debug)]
pub enum Error {
#[error(transparent)]
Io(#[from] io::Error),
@ -120,7 +120,7 @@ enum MissingLibrary {
DeprecatedModule(String, Version),
}
#[derive(Debug, Error)]
#[derive(Debug, Error, traversable_error::TraversableError)]
pub struct MissingHeaderCause {
missing_library: MissingLibrary,
package_name: Option<PackageName>,
@ -248,7 +248,7 @@ impl Display for MissingHeaderCause {
}
}
#[derive(Debug, Error)]
#[derive(Debug, Error, traversable_error::TraversableError)]
pub struct BuildBackendError {
message: String,
exit_code: ExitStatus,
@ -287,7 +287,7 @@ impl Display for BuildBackendError {
}
}
#[derive(Debug, Error)]
#[derive(Debug, Error, traversable_error::TraversableError)]
pub struct MissingHeaderError {
message: String,
exit_code: ExitStatus,

View file

@ -40,7 +40,7 @@ use uv_types::{
};
use uv_workspace::WorkspaceCache;
#[derive(Debug, Error)]
#[derive(Debug, Error, traversable_error::TraversableError)]
pub enum BuildDispatchError {
#[error(transparent)]
BuildFrontend(#[from] AnyErrorBuild),

View file

@ -5,7 +5,7 @@ use thiserror::Error;
use uv_normalize::{InvalidNameError, PackageName};
use uv_pep440::{Version, VersionParseError};
#[derive(Error, Debug)]
#[derive(Error, traversable_error::TraversableError, Debug)]
pub enum EggInfoFilenameError {
#[error("The filename \"{0}\" does not end in `.egg-info`")]
InvalidExtension(String),

View file

@ -104,7 +104,7 @@ impl Display for SourceDistExtension {
}
}
#[derive(Error, Debug)]
#[derive(Error, traversable_error::TraversableError, Debug)]
pub enum ExtensionError {
#[error("`.whl`, `.tar.gz`, `.zip`, `.tar.bz2`, `.tar.lz`, `.tar.lzma`, `.tar.xz`, `.tar.zst`, `.tar`, `.tbz`, `.tgz`, `.tlz`, or `.txz`")]
Dist,

View file

@ -141,7 +141,7 @@ impl Display for SourceDistFilename {
}
}
#[derive(Error, Debug, Clone)]
#[derive(Error, traversable_error::TraversableError, Debug, Clone)]
pub struct SourceDistFilenameError {
filename: String,
kind: SourceDistFilenameErrorKind,
@ -157,7 +157,7 @@ impl Display for SourceDistFilenameError {
}
}
#[derive(Error, Debug, Clone)]
#[derive(Error, traversable_error::TraversableError, Debug, Clone)]
enum SourceDistFilenameErrorKind {
#[error("Name doesn't start with package name {0}")]
Filename(PackageName),

View file

@ -355,7 +355,7 @@ impl Serialize for WheelFilename {
}
}
#[derive(Error, Debug)]
#[derive(Error, traversable_error::TraversableError, Debug)]
pub enum WheelFilenameError {
#[error("The wheel filename \"{0}\" is invalid: {1}")]
InvalidWheelFileName(String, String),

View file

@ -375,7 +375,7 @@ impl<'a> From<&'a IndexUrl> for IndexMetadataRef<'a> {
}
/// An error that can occur when parsing an [`Index`].
#[derive(Error, Debug)]
#[derive(Error, traversable_error::TraversableError, Debug)]
pub enum IndexSourceError {
#[error(transparent)]
Url(#[from] IndexUrlError),

View file

@ -87,7 +87,7 @@ impl Deref for IndexName {
}
/// An error that can occur when parsing an [`IndexName`].
#[derive(Error, Debug)]
#[derive(Error, traversable_error::TraversableError, Debug)]
pub enum IndexNameError {
#[error("Index included a name, but the name was empty")]
EmptyName,

View file

@ -160,7 +160,7 @@ impl Verbatim for IndexUrl {
}
/// An error that can occur when parsing an [`IndexUrl`].
#[derive(Error, Debug)]
#[derive(Error, traversable_error::TraversableError, Debug)]
pub enum IndexUrlError {
#[error(transparent)]
Io(#[from] std::io::Error),

View file

@ -17,7 +17,7 @@ use uv_pypi_types::{DirectUrl, MetadataError};
use crate::{DistributionMetadata, InstalledMetadata, InstalledVersion, Name, VersionOrUrlRef};
#[derive(Error, Debug)]
#[derive(Error, traversable_error::TraversableError, Debug)]
pub enum InstalledDistError {
#[error(transparent)]
Io(#[from] std::io::Error),

View file

@ -22,7 +22,7 @@ use uv_pypi_types::{
ParsedUrl, ParsedUrlError, VerbatimParsedUrl,
};
#[derive(Debug, Error)]
#[derive(Debug, Error, traversable_error::TraversableError)]
pub enum RequirementError {
#[error(transparent)]
VerbatimUrlError(#[from] uv_pep508::VerbatimUrlError),

View file

@ -502,7 +502,7 @@ impl LoweredRequirement {
/// An error parsing and merging `tool.uv.sources` with
/// `project.{dependencies,optional-dependencies}`.
#[derive(Debug, Error)]
#[derive(Debug, Error, traversable_error::TraversableError)]
pub enum LoweringError {
#[error("`{0}` is included as a workspace member, but is missing an entry in `tool.uv.sources` (e.g., `{0} = {{ workspace = true }}`)")]
MissingWorkspaceSource(PackageName),

View file

@ -20,7 +20,7 @@ mod build_requires;
mod lowering;
mod requires_dist;
#[derive(Debug, Error)]
#[derive(Debug, Error, traversable_error::TraversableError)]
pub enum MetadataError {
#[error(transparent)]
Workspace(#[from] WorkspaceError),

View file

@ -9,7 +9,7 @@ mod github;
mod oid;
mod reference;
#[derive(Debug, Error)]
#[derive(Debug, Error, traversable_error::TraversableError)]
pub enum GitUrlParseError {
#[error(
"Unsupported Git URL scheme `{0}:` in `{1}` (expected one of `https:`, `ssh:`, or `file:`)"

View file

@ -24,7 +24,7 @@ impl GitOid {
}
}
#[derive(Debug, Error, PartialEq)]
#[derive(Debug, Error, traversable_error::TraversableError, PartialEq)]
pub enum OidParseError {
#[error("Object ID can be at most 40 hex characters")]
TooLong,

View file

@ -5,7 +5,7 @@ use globset::{Glob, GlobBuilder};
use owo_colors::OwoColorize;
use thiserror::Error;
#[derive(Debug, Error)]
#[derive(Debug, Error, traversable_error::TraversableError)]
pub enum PortableGlobError {
/// Shows the failing glob in the error message.
#[error(transparent)]

View file

@ -36,7 +36,7 @@ pub struct Layout {
}
/// Note: The caller is responsible for adding the path of the wheel we're installing.
#[derive(Error, Debug)]
#[derive(Error, traversable_error::TraversableError, Debug)]
pub enum Error {
#[error(transparent)]
Io(#[from] io::Error),

View file

@ -22,7 +22,7 @@ const COMPILEALL_SCRIPT: &str = include_str!("pip_compileall.py");
/// This is longer than any compilation should ever take.
const COMPILE_TIMEOUT: Duration = Duration::from_secs(60);
#[derive(Debug, Error)]
#[derive(Debug, Error, traversable_error::TraversableError)]
pub enum CompileError {
#[error("Failed to list files in `site-packages`")]
Walkdir(#[from] walkdir::Error),

View file

@ -15,7 +15,7 @@ use uv_pypi_types::ResolutionMetadata;
use zip::ZipArchive;
/// The caller is responsible for attaching the path or url we failed to read.
#[derive(Debug, Error)]
#[derive(Debug, Error, traversable_error::TraversableError)]
pub enum Error {
#[error("Failed to read `dist-info` metadata from built wheel")]
DistInfo,

View file

@ -67,7 +67,7 @@ pub struct Pep508Error<T: Pep508Url = VerbatimUrl> {
}
/// Either we have an error string from our parser or an upstream error from `url`
#[derive(Debug, Error)]
#[derive(Debug, Error, traversable_error::TraversableError)]
pub enum Pep508ErrorSource<T: Pep508Url = VerbatimUrl> {
/// An error from our parser.
#[error("{0}")]

View file

@ -317,7 +317,7 @@ impl Pep508Url for VerbatimUrl {
}
/// An error that can occur when parsing a [`VerbatimUrl`].
#[derive(Error, Debug)]
#[derive(Error, traversable_error::TraversableError, Debug)]
pub enum VerbatimUrlError {
/// Failed to parse a URL.
#[error(transparent)]

View file

@ -5,7 +5,7 @@ use std::{fmt, io};
use thiserror::Error;
#[derive(Error, Debug)]
#[derive(Error, traversable_error::TraversableError, Debug)]
pub enum PlatformError {
#[error(transparent)]
IOError(#[from] io::Error),

View file

@ -43,7 +43,7 @@ use uv_warnings::{warn_user, warn_user_once};
use crate::trusted_publishing::TrustedPublishingError;
#[derive(Error, Debug)]
#[derive(Error, traversable_error::TraversableError, Debug)]
pub enum PublishError {
#[error("The publish path is not a valid glob pattern: `{0}`")]
Pattern(String, #[source] PatternError),
@ -81,7 +81,7 @@ pub enum PublishError {
}
/// Failure to get the metadata for a specific file.
#[derive(Error, Debug)]
#[derive(Error, traversable_error::TraversableError, Debug)]
pub enum PublishPrepareError {
#[error(transparent)]
Io(#[from] io::Error),
@ -100,7 +100,7 @@ pub enum PublishPrepareError {
}
/// Failure in or after (HTTP) transport for a specific file.
#[derive(Error, Debug)]
#[derive(Error, traversable_error::TraversableError, Debug)]
pub enum PublishSendError {
#[error("Failed to send POST request")]
ReqwestMiddleware(#[source] reqwest_middleware::Error),

View file

@ -14,7 +14,7 @@ use tracing::{debug, trace};
use url::Url;
use uv_static::EnvVars;
#[derive(Debug, Error)]
#[derive(Debug, Error, traversable_error::TraversableError)]
pub enum TrustedPublishingError {
#[error("Environment variable {0} not set, is the `id-token: write` permission missing?")]
MissingEnvVar(&'static str),

View file

@ -12,7 +12,7 @@ use thiserror::Error;
#[derive(Debug, Clone, Hash, PartialEq, Eq, PartialOrd, Ord)]
pub struct Identifier(Box<str>);
#[derive(Debug, Clone, Error)]
#[derive(Debug, Clone, Error, traversable_error::TraversableError)]
pub enum IdentifierParseError {
#[error("An identifier must not be empty")]
Empty,

View file

@ -28,7 +28,7 @@ pub use requires_txt::RequiresTxt;
/// <https://github.com/PyO3/python-pkginfo-rs/blob/d719988323a0cfea86d4737116d7917f30e819e2/src/error.rs>
///
/// The error type
#[derive(Error, Debug)]
#[derive(Error, traversable_error::TraversableError, Debug)]
pub enum MetadataError {
#[error(transparent)]
MailParse(#[from] MailParseError),

View file

@ -175,7 +175,7 @@ type FindPythonResult = Result<PythonInstallation, PythonNotFound>;
/// The result of failed Python installation discovery.
///
/// See [`FindPythonResult`].
#[derive(Clone, Debug, Error)]
#[derive(Clone, Debug, Error, traversable_error::TraversableError)]
pub struct PythonNotFound {
pub request: PythonRequest,
pub python_preference: PythonPreference,
@ -209,7 +209,7 @@ pub enum PythonSource {
ParentInterpreter,
}
#[derive(Error, Debug)]
#[derive(Error, traversable_error::TraversableError, Debug)]
pub enum Error {
#[error(transparent)]
Io(#[from] io::Error),

View file

@ -33,13 +33,13 @@ struct PythonEnvironmentShared {
/// The result of failed environment discovery.
///
/// Generally this is cast from [`PythonNotFound`] by [`PythonEnvironment::find`].
#[derive(Clone, Debug, Error)]
#[derive(Clone, Debug, Error, traversable_error::TraversableError)]
pub struct EnvironmentNotFound {
request: PythonRequest,
preference: EnvironmentPreference,
}
#[derive(Clone, Debug, Error)]
#[derive(Clone, Debug, Error, traversable_error::TraversableError)]
pub struct InvalidEnvironment {
path: PathBuf,
pub kind: InvalidEnvironmentKind,

View file

@ -4,7 +4,7 @@ use std::{
};
use thiserror::Error;
#[derive(Error, Debug)]
#[derive(Error, traversable_error::TraversableError, Debug)]
pub enum Error {
#[error("Unknown Python implementation `{0}`")]
UnknownImplementation(String),

View file

@ -253,7 +253,7 @@ impl PythonInstallation {
}
}
#[derive(Error, Debug)]
#[derive(Error, traversable_error::TraversableError, Debug)]
pub enum PythonInstallationKeyError {
#[error("Failed to parse Python installation key `{0}`: {1}")]
ParseError(String, String),

View file

@ -598,7 +598,7 @@ impl ExternallyManaged {
}
}
#[derive(Debug, Error)]
#[derive(Debug, Error, traversable_error::TraversableError)]
pub struct UnexpectedResponseError {
#[source]
pub(super) err: serde_json::Error,
@ -636,7 +636,7 @@ impl Display for UnexpectedResponseError {
}
}
#[derive(Debug, Error)]
#[derive(Debug, Error, traversable_error::TraversableError)]
pub struct StatusCodeError {
pub(super) code: ExitStatus,
pub(super) stdout: String,
@ -673,7 +673,7 @@ impl Display for StatusCodeError {
}
}
#[derive(Debug, Error)]
#[derive(Debug, Error, traversable_error::TraversableError)]
pub enum Error {
#[error("Failed to query Python interpreter")]
Io(#[from] io::Error),
@ -701,7 +701,7 @@ pub enum Error {
Encode(#[from] rmp_serde::encode::Error),
}
#[derive(Debug, Error)]
#[derive(Debug, Error, traversable_error::TraversableError)]
pub struct BrokenSymlink {
pub path: PathBuf,
/// Whether the interpreter path looks like a virtual environment.
@ -735,7 +735,7 @@ enum InterpreterInfoResult {
Success(Box<InterpreterInfo>),
}
#[derive(Debug, Error, Deserialize, Serialize)]
#[derive(Debug, Error, traversable_error::TraversableError, Deserialize, Serialize)]
#[serde(tag = "kind", rename_all = "snake_case")]
pub enum InterpreterInfoError {
#[error("Could not detect a glibc or a musl libc (while running on Linux)")]

View file

@ -63,7 +63,7 @@ pub(crate) fn current_dir() -> Result<std::path::PathBuf, std::io::Error> {
.unwrap_or(std::env::current_dir())
}
#[derive(Debug, Error)]
#[derive(Debug, Error, traversable_error::TraversableError)]
pub enum Error {
#[error(transparent)]
Io(#[from] std::io::Error),

View file

@ -14,7 +14,7 @@ use thiserror::Error;
use tracing::trace;
use uv_fs::Simplified;
#[derive(Debug, Error)]
#[derive(Debug, Error, traversable_error::TraversableError)]
pub enum LibcDetectionError {
#[error("Could not detect either glibc version nor musl libc version, at least one of which is required")]
NoLibcFound,

View file

@ -27,7 +27,7 @@ use crate::platform::{Arch, Libc, Os};
use crate::python_version::PythonVersion;
use crate::{macos_dylib, sysconfig, PythonRequest, PythonVariant};
#[derive(Error, Debug)]
#[derive(Error, traversable_error::TraversableError, Debug)]
pub enum Error {
#[error(transparent)]
Io(#[from] io::Error),

View file

@ -5,7 +5,7 @@ use std::ops::Deref;
use std::{fmt, str::FromStr};
use thiserror::Error;
#[derive(Error, Debug)]
#[derive(Error, traversable_error::TraversableError, Debug)]
pub enum Error {
#[error("Unknown operating system: {0}")]
UnknownOs(String),

View file

@ -48,7 +48,7 @@ pub struct PyVenvConfiguration {
pub(crate) version: Option<PythonVersion>,
}
#[derive(Debug, Error)]
#[derive(Debug, Error, traversable_error::TraversableError)]
pub enum Error {
#[error(transparent)]
Io(#[from] io::Error),

View file

@ -125,7 +125,7 @@ fn read_registry_entry(company: &str, tag: &str, tag_key: &Key) -> Option<Window
})
}
#[derive(Debug, Error)]
#[derive(Debug, Error, traversable_error::TraversableError)]
pub enum ManagedPep514Error {
#[error("Windows has an unknown pointer width for arch: `{_0}`")]
InvalidPointerSize(Arch),

View file

@ -368,7 +368,7 @@ pub struct ToolUv {
pub sources: Option<BTreeMap<PackageName, Sources>>,
}
#[derive(Debug, Error)]
#[derive(Debug, Error, traversable_error::TraversableError)]
pub enum Pep723Error {
#[error("An opening tag (`# /// script`) was found without a closing tag (`# ///`). Ensure that every line between the opening and closing tags (including empty lines) starts with a leading `#`.")]
UnclosedBlock,

View file

@ -27,7 +27,7 @@ use uv_static::EnvVars;
mod receipt;
mod tool;
#[derive(Error, Debug)]
#[derive(Error, traversable_error::TraversableError, Debug)]
pub enum Error {
#[error(transparent)]
Io(#[from] io::Error),

View file

@ -171,7 +171,7 @@ impl LauncherKind {
}
/// Note: The caller is responsible for adding the path of the wheel we're installing.
#[derive(Error, Debug)]
#[derive(Error, traversable_error::TraversableError, Debug)]
pub enum Error {
#[error(transparent)]
Io(#[from] io::Error),

View file

@ -7,7 +7,7 @@ use uv_python::{Interpreter, PythonEnvironment};
mod virtualenv;
#[derive(Debug, Error)]
#[derive(Debug, Error, traversable_error::TraversableError)]
pub enum Error {
#[error(transparent)]
Io(#[from] io::Error),

View file

@ -141,7 +141,7 @@ impl IntoIterator for FlatDependencyGroups {
}
}
#[derive(Debug, Error)]
#[derive(Debug, Error, traversable_error::TraversableError)]
pub enum DependencyGroupError {
#[error("Failed to parse entry in group `{0}`: `{1}`")]
GroupParseError(

View file

@ -30,7 +30,7 @@ use uv_pypi_types::{
Conflicts, DependencyGroups, SchemaConflicts, SupportedEnvironments, VerbatimParsedUrl,
};
#[derive(Error, Debug)]
#[derive(Error, traversable_error::TraversableError, Debug)]
pub enum PyprojectTomlError {
#[error(transparent)]
TomlSyntax(#[from] toml_edit::TomlError),
@ -1331,7 +1331,7 @@ impl<'de> Deserialize<'de> for Source {
}
}
#[derive(Error, Debug)]
#[derive(Error, traversable_error::TraversableError, Debug)]
pub enum SourceError {
#[error("Failed to resolve Git reference: `{0}`")]
UnresolvedReference(String),

View file

@ -28,7 +28,7 @@ pub struct PyProjectTomlMut {
target: DependencyTarget,
}
#[derive(Error, Debug)]
#[derive(Error, traversable_error::TraversableError, Debug)]
pub enum Error {
#[error("Failed to parse `pyproject.toml`")]
Parse(#[from] Box<TomlError>),

View file

@ -260,8 +260,7 @@ async fn build_impl(
let workspace = match workspace {
Ok(ref workspace) => workspace,
Err(err) => {
return Err(anyhow::Error::from(err)
.context("`--package` was provided, but no workspace was found"));
return Err(err).context("`--package` was provided, but no workspace was found");
}
};
@ -289,8 +288,8 @@ async fn build_impl(
let workspace = match workspace {
Ok(ref workspace) => workspace,
Err(err) => {
return Err(anyhow::Error::from(err)
.context("`--all-packages` was provided, but no workspace was found"));
return Err(err)
.context("`--all-packages` was provided, but no workspace was found");
}
};

View file

@ -103,7 +103,7 @@ pub(crate) async fn venv(
}
}
#[derive(Error, Debug, Diagnostic)]
#[derive(Error, traversable_error::TraversableError, Debug, Diagnostic)]
enum VenvError {
#[error("Failed to create virtualenv")]
#[diagnostic(code(uv::venv::creation))]