Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ticks around error messages more consistently #3004

Merged
merged 1 commit into from
Apr 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion crates/distribution-types/src/file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use pypi_types::{DistInfoMetadata, HashDigest, Yanked};
/// Error converting [`pypi_types::File`] to [`distribution_type::File`].
#[derive(Debug, Error)]
pub enum FileConversionError {
#[error("Failed to parse 'requires-python': {0}")]
#[error("Failed to parse 'requires-python': `{0}`")]
RequiresPython(String, #[source] VersionSpecifiersParseError),
#[error("Failed to parse URL: {0}")]
Url(String, #[source] url::ParseError),
Expand Down
8 changes: 4 additions & 4 deletions crates/platform-tags/src/tags.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ use crate::{Arch, Os, Platform, PlatformError};
pub enum TagsError {
#[error(transparent)]
PlatformError(#[from] PlatformError),
#[error("Unsupported implementation: {0}")]
#[error("Unsupported implementation: `{0}`")]
UnsupportedImplementation(String),
#[error("Unknown implementation: {0}")]
#[error("Unknown implementation: `{0}`")]
UnknownImplementation(String),
#[error("Invalid priority: {0}")]
#[error("Invalid priority: `{0}`")]
InvalidPriority(usize, #[source] std::num::TryFromIntError),
#[error("Only CPython can be freethreading, not: {0}")]
GilIsACpythonProblem(String),
Expand All @@ -36,7 +36,7 @@ pub enum TagCompatibility {
}

impl Ord for TagCompatibility {
fn cmp(&self, other: &Self) -> std::cmp::Ordering {
fn cmp(&self, other: &Self) -> cmp::Ordering {
match (self, other) {
(Self::Compatible(p_self), Self::Compatible(p_other)) => p_self.cmp(p_other),
(Self::Incompatible(_), Self::Compatible(_)) => cmp::Ordering::Less,
Expand Down
18 changes: 9 additions & 9 deletions crates/uv-distribution/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ pub enum Error {
NoBinary,

// Network error
#[error("Failed to parse URL: `{0}`")]
#[error("Failed to parse URL: {0}")]
Url(String, #[source] url::ParseError),
#[error(transparent)]
JoinRelativeUrl(#[from] pypi_types::JoinRelativeError),
Expand All @@ -41,9 +41,9 @@ pub enum Error {
CacheEncode(#[from] rmp_serde::encode::Error),

// Build error
#[error("Failed to build: {0}")]
#[error("Failed to build: `{0}`")]
Build(String, #[source] anyhow::Error),
#[error("Failed to build editable: {0}")]
#[error("Failed to build editable: `{0}`")]
BuildEditable(String, #[source] anyhow::Error),
#[error("Built wheel has an invalid filename")]
WheelFilename(#[from] WheelFilenameError),
Expand Down Expand Up @@ -90,34 +90,34 @@ pub enum Error {
#[error("Failed to hash distribution")]
HashExhaustion(#[source] std::io::Error),

#[error("Hash mismatch for {distribution}\n\nExpected:\n{expected}\n\nComputed:\n{actual}")]
#[error("Hash mismatch for `{distribution}`\n\nExpected:\n{expected}\n\nComputed:\n{actual}")]
MismatchedHashes {
distribution: String,
expected: String,
actual: String,
},

#[error(
"Hash-checking is enabled, but no hashes were provided or computed for: {distribution}"
"Hash-checking is enabled, but no hashes were provided or computed for: `{distribution}`"
)]
MissingHashes { distribution: String },

#[error("Hash-checking is enabled, but no hashes were computed for: {distribution}\n\nExpected:\n{expected}")]
#[error("Hash-checking is enabled, but no hashes were computed for: `{distribution}`\n\nExpected:\n{expected}")]
MissingActualHashes {
distribution: String,
expected: String,
},

#[error("Hash-checking is enabled, but no hashes were provided for: {distribution}\n\nComputed:\n{actual}")]
#[error("Hash-checking is enabled, but no hashes were provided for: `{distribution}`\n\nComputed:\n{actual}")]
MissingExpectedHashes {
distribution: String,
actual: String,
},

#[error("Hash-checking is not supported for local directories: {0}")]
#[error("Hash-checking is not supported for local directories: `{0}`")]
HashesNotSupportedSourceTree(String),

#[error("Hash-checking is not supported for Git repositories: {0}")]
#[error("Hash-checking is not supported for Git repositories: `{0}`")]
HashesNotSupportedGit(String),
}

Expand Down
16 changes: 8 additions & 8 deletions crates/uv-resolver/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ use crate::resolver::{IncompletePackage, UnavailablePackage, VersionsResponse};

#[derive(Debug, thiserror::Error)]
pub enum ResolveError {
#[error("Failed to find a version of {0} that satisfies the requirement")]
#[error("Failed to find a version of `{0}` that satisfies the requirement")]
NotFound(Requirement),

#[error(transparent)]
Expand All @@ -46,7 +46,7 @@ pub enum ResolveError {
metadata: PackageName,
},

#[error("~= operator requires at least two release segments: {0}")]
#[error("~= operator requires at least two release segments: `{0}`")]
InvalidTildeEquals(pep440_rs::VersionSpecifier),

#[error("Requirements contain conflicting URLs for package `{0}`:\n- {1}\n- {2}")]
Expand All @@ -64,20 +64,20 @@ pub enum ResolveError {
#[error(transparent)]
DistributionType(#[from] distribution_types::Error),

#[error("Failed to download: {0}")]
#[error("Failed to download `{0}`")]
Fetch(Box<BuiltDist>, #[source] uv_distribution::Error),

#[error("Failed to download and build: {0}")]
#[error("Failed to download and build `{0}`")]
FetchAndBuild(Box<SourceDist>, #[source] uv_distribution::Error),

#[error("Failed to read: {0}")]
#[error("Failed to read `{0}`")]
Read(Box<PathBuiltDist>, #[source] uv_distribution::Error),

// TODO(zanieb): Use `thiserror` in `InstalledDist` so we can avoid chaining `anyhow`
#[error("Failed to read metadata from installed package: {0}")]
#[error("Failed to read metadata from installed package `{0}`")]
ReadInstalled(Box<InstalledDist>, #[source] anyhow::Error),

#[error("Failed to build: {0}")]
#[error("Failed to build `{0}`")]
Build(Box<PathSourceDist>, #[source] uv_distribution::Error),

#[error(transparent)]
Expand All @@ -94,7 +94,7 @@ pub enum ResolveError {
#[error("Attempted to construct an invalid version specifier")]
InvalidVersion(#[from] pep440_rs::VersionSpecifierBuildError),

#[error("In `--require-hashes` mode, all requirements must be pinned upfront with `==`, but found: {0}")]
#[error("In `--require-hashes` mode, all requirements must be pinned upfront with `==`, but found: `{0}`")]
UnhashedPackage(PackageName),

/// Something unexpected happened.
Expand Down
2 changes: 1 addition & 1 deletion crates/uv-resolver/src/preferences.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use uv_normalize::PackageName;

#[derive(thiserror::Error, Debug)]
pub enum PreferenceError {
#[error("direct URL requirements without package names are not supported: {0}")]
#[error("direct URL requirements without package names are not supported: `{0}`")]
Bare(UnnamedRequirement),
#[error(transparent)]
Hash(#[from] HashError),
Expand Down
14 changes: 7 additions & 7 deletions crates/uv/tests/pip_install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ dependencies = ["flask==1.0.x"]
----- stdout -----

----- stderr -----
error: Failed to build: file://[TEMP_DIR]/
error: Failed to build: `file://[TEMP_DIR]/`
Caused by: Build backend failed to determine extra requires with `build_wheel()` with exit code: 1
--- stdout:
configuration error: `project.dependencies[0]` must be pep508
Expand Down Expand Up @@ -2626,7 +2626,7 @@ fn no_build_isolation() -> Result<()> {

----- stderr -----
error: Failed to download and build: anyio @ https://files.pythonhosted.org/packages/db/4d/3970183622f0330d3c23d9b8a5f52e365e50381fd484d08e3285104333d3/anyio-4.3.0.tar.gz
Caused by: Failed to build: anyio @ https://files.pythonhosted.org/packages/db/4d/3970183622f0330d3c23d9b8a5f52e365e50381fd484d08e3285104333d3/anyio-4.3.0.tar.gz
Caused by: Failed to build: `anyio @ https://files.pythonhosted.org/packages/db/4d/3970183622f0330d3c23d9b8a5f52e365e50381fd484d08e3285104333d3/anyio-4.3.0.tar.gz`
Caused by: Build backend failed to determine metadata through `prepare_metadata_for_build_wheel` with exit status: 1
--- stdout:

Expand Down Expand Up @@ -3242,7 +3242,7 @@ fn install_package_basic_auth_from_keyring_wrong_password() {
----- stdout -----

----- stderr -----
error: Failed to download: anyio==4.3.0
error: Failed to download `anyio==4.3.0`
Caused by: HTTP status client error (401 Unauthorized) for url (https://pypi-proxy.fly.dev/basic-auth/files/packages/14/fd/2f20c40b45e4fb4324834aea24bd4afdf1143390242c0b33774da0e2e34f/anyio-4.3.0-py3-none-any.whl.metadata)
"###
);
Expand Down Expand Up @@ -3281,7 +3281,7 @@ fn install_package_basic_auth_from_keyring_wrong_username() {
----- stdout -----

----- stderr -----
error: Failed to download: anyio==4.3.0
error: Failed to download `anyio==4.3.0`
Caused by: HTTP status client error (401 Unauthorized) for url (https://pypi-proxy.fly.dev/basic-auth/files/packages/14/fd/2f20c40b45e4fb4324834aea24bd4afdf1143390242c0b33774da0e2e34f/anyio-4.3.0-py3-none-any.whl.metadata)
"###
);
Expand Down Expand Up @@ -4206,7 +4206,7 @@ fn require_hashes_mismatch() -> Result<()> {
----- stdout -----

----- stderr -----
error: In `--require-hashes` mode, all requirements must be pinned upfront with `==`, but found: idna
error: In `--require-hashes` mode, all requirements must be pinned upfront with `==`, but found: `idna`
"###
);

Expand Down Expand Up @@ -4234,7 +4234,7 @@ fn require_hashes_missing_dependency() -> Result<()> {
----- stdout -----

----- stderr -----
error: In `--require-hashes` mode, all requirements must be pinned upfront with `==`, but found: idna
error: In `--require-hashes` mode, all requirements must be pinned upfront with `==`, but found: `idna`
"###
);

Expand Down Expand Up @@ -4264,7 +4264,7 @@ fn require_hashes_editable() -> Result<()> {

----- stderr -----
Built 1 editable in [TIME]
error: In `--require-hashes` mode, all requirements must be pinned upfront with `==`, but found: aiohttp
error: In `--require-hashes` mode, all requirements must be pinned upfront with `==`, but found: `aiohttp`
"###
);

Expand Down
Loading
Loading