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

View file

@ -130,7 +130,6 @@ path-slash = { version = "0.2.1" }
pathdiff = { version = "0.2.1" } pathdiff = { version = "0.2.1" }
percent-encoding = { version = "2.3.1" } percent-encoding = { version = "2.3.1" }
petgraph = { version = "0.7.1" } petgraph = { version = "0.7.1" }
platform-info = { version = "2.0.3" }
proc-macro2 = { version = "1.0.86" } proc-macro2 = { version = "1.0.86" }
procfs = { version = "0.17.0", default-features = false, features = ["flate2"] } procfs = { version = "0.17.0", default-features = false, features = ["flate2"] }
pubgrub = { git = "https://github.com/astral-sh/pubgrub", rev = "b70cf707aa43f21b32f3a61b8a0889b15032d5c4" } 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 crate::metadata::ValidationError;
use std::fs::FileType; use std::fs::FileType;
use std::io; use std::io;
use std::path::{Path, PathBuf, StripPrefixError}; use std::path::{Path, PathBuf};
use thiserror::Error; use thiserror::Error;
use tracing::debug; use tracing::debug;
use uv_fs::Simplified; use uv_fs::Simplified;
@ -36,13 +36,6 @@ pub enum Error {
#[source] #[source]
source: globset::Error, 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")] #[error("`pyproject.toml` must not be excluded from source distribution build")]
PyprojectTomlExcluded, PyprojectTomlExcluded,
#[error("Failed to walk source tree: `{}`", root.user_display())] #[error("Failed to walk source tree: `{}`", root.user_display())]
@ -51,8 +44,6 @@ pub enum Error {
#[source] #[source]
err: walkdir::Error, err: walkdir::Error,
}, },
#[error("Failed to walk source tree")]
StripPrefix(#[from] StripPrefixError),
#[error("Unsupported file type {:?}: `{}`", _1, _0.user_display())] #[error("Unsupported file type {:?}: `{}`", _1, _0.user_display())]
UnsupportedFileType(PathBuf, FileType), UnsupportedFileType(PathBuf, FileType),
#[error("Failed to write wheel zip archive")] #[error("Failed to write wheel zip archive")]

View file

@ -66,8 +66,6 @@ pub enum Error {
InvalidPyprojectTomlSyntax(#[from] toml_edit::TomlError), 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.")] #[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), 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}")] #[error("Failed to resolve requirements from {0}")]
RequirementsResolve(&'static str, #[source] AnyErrorBuild), RequirementsResolve(&'static str, #[source] AnyErrorBuild),
#[error("Failed to install requirements from {0}")] #[error("Failed to install requirements from {0}")]
@ -100,7 +98,6 @@ impl IsBuildBackendError for Error {
| Self::InvalidSourceDist(_) | Self::InvalidSourceDist(_)
| Self::InvalidPyprojectTomlSyntax(_) | Self::InvalidPyprojectTomlSyntax(_)
| Self::InvalidPyprojectTomlSchema(_) | Self::InvalidPyprojectTomlSchema(_)
| Self::EditableSetupPy
| Self::RequirementsResolve(_, _) | Self::RequirementsResolve(_, _)
| Self::RequirementsInstall(_, _) | Self::RequirementsInstall(_, _)
| Self::Virtualenv(_) | Self::Virtualenv(_)

View file

@ -12,7 +12,7 @@ use uv_distribution_types::{InstalledDist, InstalledDistError, IsBuildBackendErr
use uv_fs::Simplified; use uv_fs::Simplified;
use uv_normalize::PackageName; use uv_normalize::PackageName;
use uv_pep440::{Version, VersionSpecifiers}; use uv_pep440::{Version, VersionSpecifiers};
use uv_pypi_types::{HashAlgorithm, HashDigest, ParsedUrlError}; use uv_pypi_types::{HashAlgorithm, HashDigest};
use uv_types::AnyErrorBuild; use uv_types::AnyErrorBuild;
#[derive(Debug, thiserror::Error)] #[derive(Debug, thiserror::Error)]
@ -26,8 +26,6 @@ pub enum Error {
#[error(transparent)] #[error(transparent)]
InvalidUrl(#[from] uv_distribution_types::ToUrlError), InvalidUrl(#[from] uv_distribution_types::ToUrlError),
#[error(transparent)] #[error(transparent)]
ParsedUrl(#[from] ParsedUrlError),
#[error(transparent)]
JoinRelativeUrl(#[from] uv_pypi_types::JoinRelativeError), JoinRelativeUrl(#[from] uv_pypi_types::JoinRelativeError),
#[error("Expected a file URL, but received: {0}")] #[error("Expected a file URL, but received: {0}")]
NonFileUrl(Url), NonFileUrl(Url),
@ -86,8 +84,6 @@ pub enum Error {
ReadInstalled(Box<InstalledDist>, #[source] InstalledDistError), ReadInstalled(Box<InstalledDist>, #[source] InstalledDistError),
#[error("Failed to read zip archive from built wheel")] #[error("Failed to read zip archive from built wheel")]
Zip(#[from] ZipError), 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")] #[error("Failed to extract archive")]
Extract(#[from] uv_extract::Error), Extract(#[from] uv_extract::Error),
#[error("The source distribution is missing a `PKG-INFO` file")] #[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)] #[derive(Debug, thiserror::Error)]
pub enum Error { pub enum Error {
@ -8,8 +8,6 @@ pub enum Error {
AsyncZip(#[from] async_zip::error::ZipError), AsyncZip(#[from] async_zip::error::ZipError),
#[error(transparent)] #[error(transparent)]
Io(#[from] std::io::Error), Io(#[from] std::io::Error),
#[error("Unsupported archive type: {0}")]
UnsupportedArchive(PathBuf),
#[error( #[error(
"The top-level of the archive must only contain a list directory, but it contains: {0:?}" "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-fs = { workspace = true }
uv-normalize = { workspace = true } uv-normalize = { workspace = true }
uv-pep440 = { workspace = true } uv-pep440 = { workspace = true }
uv-platform-tags = { workspace = true }
uv-pypi-types = { workspace = true } uv-pypi-types = { workspace = true }
uv-shell = { workspace = true } uv-shell = { workspace = true }
uv-trampoline-builder = { workspace = true } uv-trampoline-builder = { workspace = true }
@ -39,7 +38,6 @@ data-encoding = { workspace = true }
fs-err = { workspace = true } fs-err = { workspace = true }
mailparse = { workspace = true } mailparse = { workspace = true }
pathdiff = { workspace = true } pathdiff = { workspace = true }
platform-info = { workspace = true }
reflink-copy = { workspace = true } reflink-copy = { workspace = true }
regex = { workspace = true } regex = { workspace = true }
rustc-hash = { workspace = true } rustc-hash = { workspace = true }
@ -51,7 +49,6 @@ tempfile = { workspace = true }
thiserror = { workspace = true } thiserror = { workspace = true }
tracing = { workspace = true } tracing = { workspace = true }
walkdir = { workspace = true } walkdir = { workspace = true }
zip = { workspace = true }
[target.'cfg(target_os = "windows")'.dependencies] [target.'cfg(target_os = "windows")'.dependencies]
same-file = { workspace = true } same-file = { workspace = true }

View file

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

View file

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

View file

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

View file

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