Remove unused thiserror variants (#11713)

## Summary

We get to remove an entire dependency too.
This commit is contained in:
Charlie Marsh 2025-02-22 12:12:22 -10:00 committed by GitHub
parent 0b3d91c73a
commit 359a3cbe44
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
11 changed files with 8 additions and 75 deletions

14
Cargo.lock generated
View file

@ -2615,16 +2615,6 @@ version = "0.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b4596b6d070b27117e987119b4dac604f3c58cfb0b191112e24771b2faeac1a6"
[[package]]
name = "platform-info"
version = "2.0.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7539aeb3fdd8cb4f6a331307cf71a1039cee75e94e8a71725b9484f4a0d9451a"
dependencies = [
"libc",
"winapi",
]
[[package]]
name = "png"
version = "0.17.16"
@ -5198,7 +5188,6 @@ dependencies = [
"indoc",
"mailparse",
"pathdiff",
"platform-info",
"reflink-copy",
"regex",
"rustc-hash",
@ -5216,13 +5205,11 @@ dependencies = [
"uv-fs",
"uv-normalize",
"uv-pep440",
"uv-platform-tags",
"uv-pypi-types",
"uv-shell",
"uv-trampoline-builder",
"uv-warnings",
"walkdir",
"zip",
]
[[package]]
@ -5789,7 +5776,6 @@ dependencies = [
"thiserror 2.0.11",
"tracing",
"uv-fs",
"uv-platform-tags",
"uv-pypi-types",
"uv-python",
"uv-shell",

View file

@ -130,7 +130,6 @@ path-slash = { version = "0.2.1" }
pathdiff = { version = "0.2.1" }
percent-encoding = { version = "2.3.1" }
petgraph = { version = "0.7.1" }
platform-info = { version = "2.0.3" }
proc-macro2 = { version = "1.0.86" }
procfs = { version = "0.17.0", default-features = false, features = ["flate2"] }
pubgrub = { git = "https://github.com/astral-sh/pubgrub", rev = "b70cf707aa43f21b32f3a61b8a0889b15032d5c4" }

View file

@ -9,7 +9,7 @@ pub use wheel::{build_editable, build_wheel, list_wheel, metadata};
use crate::metadata::ValidationError;
use std::fs::FileType;
use std::io;
use std::path::{Path, PathBuf, StripPrefixError};
use std::path::{Path, PathBuf};
use thiserror::Error;
use tracing::debug;
use uv_fs::Simplified;
@ -36,13 +36,6 @@ pub enum Error {
#[source]
source: globset::Error,
},
/// [`globset::Error`] shows the glob that failed to parse.
#[error("Unsupported glob expression in: `{field}`")]
GlobSet {
field: String,
#[source]
err: globset::Error,
},
#[error("`pyproject.toml` must not be excluded from source distribution build")]
PyprojectTomlExcluded,
#[error("Failed to walk source tree: `{}`", root.user_display())]
@ -51,8 +44,6 @@ pub enum Error {
#[source]
err: walkdir::Error,
},
#[error("Failed to walk source tree")]
StripPrefix(#[from] StripPrefixError),
#[error("Unsupported file type {:?}: `{}`", _1, _0.user_display())]
UnsupportedFileType(PathBuf, FileType),
#[error("Failed to write wheel zip archive")]

View file

@ -66,8 +66,6 @@ pub enum Error {
InvalidPyprojectTomlSyntax(#[from] toml_edit::TomlError),
#[error("`pyproject.toml` does not match the required schema. When the `[project]` table is present, `project.name` must be present and non-empty.")]
InvalidPyprojectTomlSchema(#[from] toml_edit::de::Error),
#[error("Editable installs with setup.py legacy builds are unsupported, please specify a build backend in pyproject.toml")]
EditableSetupPy,
#[error("Failed to resolve requirements from {0}")]
RequirementsResolve(&'static str, #[source] AnyErrorBuild),
#[error("Failed to install requirements from {0}")]
@ -100,7 +98,6 @@ impl IsBuildBackendError for Error {
| Self::InvalidSourceDist(_)
| Self::InvalidPyprojectTomlSyntax(_)
| Self::InvalidPyprojectTomlSchema(_)
| Self::EditableSetupPy
| Self::RequirementsResolve(_, _)
| Self::RequirementsInstall(_, _)
| Self::Virtualenv(_)

View file

@ -12,7 +12,7 @@ use uv_distribution_types::{InstalledDist, InstalledDistError, IsBuildBackendErr
use uv_fs::Simplified;
use uv_normalize::PackageName;
use uv_pep440::{Version, VersionSpecifiers};
use uv_pypi_types::{HashAlgorithm, HashDigest, ParsedUrlError};
use uv_pypi_types::{HashAlgorithm, HashDigest};
use uv_types::AnyErrorBuild;
#[derive(Debug, thiserror::Error)]
@ -26,8 +26,6 @@ pub enum Error {
#[error(transparent)]
InvalidUrl(#[from] uv_distribution_types::ToUrlError),
#[error(transparent)]
ParsedUrl(#[from] ParsedUrlError),
#[error(transparent)]
JoinRelativeUrl(#[from] uv_pypi_types::JoinRelativeError),
#[error("Expected a file URL, but received: {0}")]
NonFileUrl(Url),
@ -86,8 +84,6 @@ pub enum Error {
ReadInstalled(Box<InstalledDist>, #[source] InstalledDistError),
#[error("Failed to read zip archive from built wheel")]
Zip(#[from] ZipError),
#[error("Source distribution directory contains neither readable `pyproject.toml` nor `setup.py`: `{}`", _0.user_display())]
DirWithoutEntrypoint(PathBuf),
#[error("Failed to extract archive")]
Extract(#[from] uv_extract::Error),
#[error("The source distribution is missing a `PKG-INFO` file")]

View file

@ -1,4 +1,4 @@
use std::{ffi::OsString, path::PathBuf};
use std::ffi::OsString;
#[derive(Debug, thiserror::Error)]
pub enum Error {
@ -8,8 +8,6 @@ pub enum Error {
AsyncZip(#[from] async_zip::error::ZipError),
#[error(transparent)]
Io(#[from] std::io::Error),
#[error("Unsupported archive type: {0}")]
UnsupportedArchive(PathBuf),
#[error(
"The top-level of the archive must only contain a list directory, but it contains: {0:?}"
)]

View file

@ -26,7 +26,6 @@ uv-distribution-filename = { workspace = true }
uv-fs = { workspace = true }
uv-normalize = { workspace = true }
uv-pep440 = { workspace = true }
uv-platform-tags = { workspace = true }
uv-pypi-types = { workspace = true }
uv-shell = { workspace = true }
uv-trampoline-builder = { workspace = true }
@ -39,7 +38,6 @@ data-encoding = { workspace = true }
fs-err = { workspace = true }
mailparse = { workspace = true }
pathdiff = { workspace = true }
platform-info = { workspace = true }
reflink-copy = { workspace = true }
regex = { workspace = true }
rustc-hash = { workspace = true }
@ -51,7 +49,6 @@ tempfile = { workspace = true }
thiserror = { workspace = true }
tracing = { workspace = true }
walkdir = { workspace = true }
zip = { workspace = true }
[target.'cfg(target_os = "windows")'.dependencies]
same-file = { workspace = true }

View file

@ -3,14 +3,11 @@
use std::io;
use std::path::PathBuf;
use platform_info::PlatformInfoError;
use thiserror::Error;
use zip::result::ZipError;
use uv_fs::Simplified;
use uv_normalize::PackageName;
use uv_pep440::Version;
use uv_platform_tags::{Arch, Os};
use uv_pypi_types::Scheme;
pub use install::install_wheel;
@ -51,20 +48,10 @@ pub enum Error {
#[source]
err: io::Error,
},
/// Tags/metadata didn't match platform
#[error("The wheel is incompatible with the current platform {os} {arch}")]
IncompatibleWheel { os: Os, arch: Arch },
/// The wheel is broken
#[error("The wheel is invalid: {0}")]
InvalidWheel(String),
/// Doesn't follow file name schema
#[error(transparent)]
InvalidWheelFileName(#[from] uv_distribution_filename::WheelFilenameError),
/// The caller must add the name of the zip file (See note on type).
#[error("Failed to read {0} from zip file")]
Zip(String, #[source] ZipError),
#[error("Failed to run Python subcommand")]
PythonSubcommand(#[source] io::Error),
#[error("Failed to move data files")]
WalkDir(#[from] walkdir::Error),
#[error("RECORD file doesn't match wheel contents: {0}")]
@ -79,20 +66,12 @@ pub enum Error {
UnsupportedWindowsArch(&'static str),
#[error("Unable to create Windows launcher on non-Windows platform")]
NotWindows,
#[error("Failed to detect the current platform")]
PlatformInfo(#[source] PlatformInfoError),
#[error("Invalid version specification, only none or == is supported")]
Pep440,
#[error("Invalid direct_url.json")]
#[error("Invalid `direct_url.json`")]
DirectUrlJson(#[from] serde_json::Error),
#[error("Cannot uninstall package; `RECORD` file not found at: {}", _0.user_display())]
MissingRecord(PathBuf),
#[error("Cannot uninstall package; `top_level.txt` file not found at: {}", _0.user_display())]
MissingTopLevel(PathBuf),
#[error("Invalid wheel size")]
InvalidSize,
#[error("Invalid package name")]
InvalidName(#[from] uv_normalize::InvalidNameError),
#[error("Invalid package version")]
InvalidVersion(#[from] uv_pep440::VersionParseError),
#[error("Wheel package name does not match filename: {0} != {1}")]

View file

@ -32,15 +32,13 @@ pub enum Error {
#[error(transparent)]
Io(#[from] io::Error),
#[error("Failed to update `uv-receipt.toml` at {0}")]
ReceiptWrite(PathBuf, #[source] Box<toml::ser::Error>),
ReceiptWrite(PathBuf, #[source] Box<toml_edit::ser::Error>),
#[error("Failed to read `uv-receipt.toml` at {0}")]
ReceiptRead(PathBuf, #[source] Box<toml::de::Error>),
#[error(transparent)]
VirtualEnvError(#[from] uv_virtualenv::Error),
#[error("Failed to read package entry points {0}")]
EntrypointRead(#[from] uv_install_wheel::Error),
#[error("Failed to find dist-info directory `{0}` in environment at {1}")]
DistInfoMissing(String, PathBuf),
#[error("Failed to find a directory to install executables into")]
NoExecutableDirectory,
#[error(transparent)]
@ -53,8 +51,6 @@ pub enum Error {
EnvironmentRead(PathBuf, String),
#[error("Failed find package `{0}` in tool environment")]
MissingToolPackage(PackageName),
#[error(transparent)]
Serialization(#[from] toml_edit::ser::Error),
}
/// A collection of uv-managed tools installed on the current system.
@ -159,7 +155,9 @@ impl InstalledTools {
path.user_display()
);
let doc = tool_receipt.to_toml()?;
let doc = tool_receipt
.to_toml()
.map_err(|err| Error::ReceiptWrite(path.clone(), Box::new(err)))?;
// Save the modified `uv-receipt.toml`.
fs_err::write(&path, doc)?;

View file

@ -21,7 +21,6 @@ workspace = true
[dependencies]
uv-fs = { workspace = true }
uv-platform-tags = { workspace = true }
uv-pypi-types = { workspace = true }
uv-python = { workspace = true }
uv-shell = { workspace = true }

View file

@ -3,7 +3,6 @@ use std::path::Path;
use thiserror::Error;
use uv_platform_tags::PlatformError;
use uv_python::{Interpreter, PythonEnvironment};
mod virtualenv;
@ -12,12 +11,6 @@ mod virtualenv;
pub enum Error {
#[error(transparent)]
Io(#[from] io::Error),
#[error("Failed to determine Python interpreter to use")]
Discovery(#[from] uv_python::DiscoveryError),
#[error("Failed to determine Python interpreter to use")]
InterpreterNotFound(#[from] uv_python::PythonNotFound),
#[error(transparent)]
Platform(#[from] PlatformError),
#[error("Could not find a suitable Python executable for the virtual environment based on the interpreter: {0}")]
NotFound(String),
}