Capitalize error messages from lockfile (#8115)

## Summary

This is more consistent with how we format errors everywhere else.
This commit is contained in:
Charlie Marsh 2024-10-11 01:50:00 +02:00 committed by GitHub
parent 538de64533
commit 2506c1c274
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 47 additions and 47 deletions

View File

@ -3780,14 +3780,14 @@ where
enum LockErrorKind { enum LockErrorKind {
/// An error that occurs when multiple packages with the same /// An error that occurs when multiple packages with the same
/// ID were found. /// ID were found.
#[error("found duplicate package `{id}`")] #[error("Found duplicate package `{id}`")]
DuplicatePackage { DuplicatePackage {
/// The ID of the conflicting package. /// The ID of the conflicting package.
id: PackageId, id: PackageId,
}, },
/// An error that occurs when there are multiple dependencies for the /// An error that occurs when there are multiple dependencies for the
/// same package that have identical identifiers. /// same package that have identical identifiers.
#[error("for package `{id}`, found duplicate dependency `{dependency}`")] #[error("For package `{id}`, found duplicate dependency `{dependency}`")]
DuplicateDependency { DuplicateDependency {
/// The ID of the package for which a duplicate dependency was /// The ID of the package for which a duplicate dependency was
/// found. /// found.
@ -3798,7 +3798,7 @@ enum LockErrorKind {
/// An error that occurs when there are multiple dependencies for the /// An error that occurs when there are multiple dependencies for the
/// same package that have identical identifiers, as part of the /// same package that have identical identifiers, as part of the
/// that package's optional dependencies. /// that package's optional dependencies.
#[error("for package `{id}[{extra}]`, found duplicate dependency `{dependency}`")] #[error("For package `{id}[{extra}]`, found duplicate dependency `{dependency}`")]
DuplicateOptionalDependency { DuplicateOptionalDependency {
/// The ID of the package for which a duplicate dependency was /// The ID of the package for which a duplicate dependency was
/// found. /// found.
@ -3811,7 +3811,7 @@ enum LockErrorKind {
/// An error that occurs when there are multiple dependencies for the /// An error that occurs when there are multiple dependencies for the
/// same package that have identical identifiers, as part of the /// same package that have identical identifiers, as part of the
/// that package's development dependencies. /// that package's development dependencies.
#[error("for package `{id}:{group}`, found duplicate dependency `{dependency}`")] #[error("For package `{id}:{group}`, found duplicate dependency `{dependency}`")]
DuplicateDevDependency { DuplicateDevDependency {
/// The ID of the package for which a duplicate dependency was /// The ID of the package for which a duplicate dependency was
/// found. /// found.
@ -3823,7 +3823,7 @@ enum LockErrorKind {
}, },
/// An error that occurs when the URL to a file for a wheel or /// An error that occurs when the URL to a file for a wheel or
/// source dist could not be converted to a structured `url::Url`. /// source dist could not be converted to a structured `url::Url`.
#[error("failed to parse wheel or source distribution URL")] #[error("Failed to parse wheel or source distribution URL")]
InvalidFileUrl( InvalidFileUrl(
/// The underlying error that occurred. This includes the /// The underlying error that occurred. This includes the
/// errant URL in its error message. /// errant URL in its error message.
@ -3832,10 +3832,10 @@ enum LockErrorKind {
), ),
/// An error that occurs when the extension can't be determined /// An error that occurs when the extension can't be determined
/// for a given wheel or source distribution. /// for a given wheel or source distribution.
#[error("failed to parse file extension; expected one of: {0}")] #[error("Failed to parse file extension; expected one of: {0}")]
MissingExtension(#[from] ExtensionError), MissingExtension(#[from] ExtensionError),
/// Failed to parse a git source URL. /// Failed to parse a git source URL.
#[error("failed to parse source git URL")] #[error("Failed to parse source git URL")]
InvalidGitSourceUrl( InvalidGitSourceUrl(
/// The underlying error that occurred. This includes the /// The underlying error that occurred. This includes the
/// errant URL in the message. /// errant URL in the message.
@ -3845,7 +3845,7 @@ enum LockErrorKind {
/// An error that occurs when there's an unrecognized dependency. /// An error that occurs when there's an unrecognized dependency.
/// ///
/// That is, a dependency for a package that isn't in the lockfile. /// That is, a dependency for a package that isn't in the lockfile.
#[error("for package `{id}`, found dependency `{dependency}` with no locked package")] #[error("For package `{id}`, found dependency `{dependency}` with no locked package")]
UnrecognizedDependency { UnrecognizedDependency {
/// The ID of the package that has an unrecognized dependency. /// The ID of the package that has an unrecognized dependency.
id: PackageId, id: PackageId,
@ -3855,7 +3855,7 @@ enum LockErrorKind {
}, },
/// An error that occurs when a hash is expected (or not) for a particular /// An error that occurs when a hash is expected (or not) for a particular
/// artifact, but one was not found (or was). /// artifact, but one was not found (or was).
#[error("since the package `{id}` comes from a {source} dependency, a hash was {expected} but one was not found for {artifact_type}", source = id.source.name(), expected = if *expected { "expected" } else { "not expected" })] #[error("Since the package `{id}` comes from a {source} dependency, a hash was {expected} but one was not found for {artifact_type}", source = id.source.name(), expected = if *expected { "expected" } else { "not expected" })]
Hash { Hash {
/// The ID of the package that has a missing hash. /// The ID of the package that has a missing hash.
id: PackageId, id: PackageId,
@ -3867,7 +3867,7 @@ enum LockErrorKind {
}, },
/// An error that occurs when a package is included with an extra name, /// An error that occurs when a package is included with an extra name,
/// but no corresponding base package (i.e., without the extra) exists. /// but no corresponding base package (i.e., without the extra) exists.
#[error("found package `{id}` with extra `{extra}` but no base package")] #[error("Found package `{id}` with extra `{extra}` but no base package")]
MissingExtraBase { MissingExtraBase {
/// The ID of the package that has a missing base. /// The ID of the package that has a missing base.
id: PackageId, id: PackageId,
@ -3888,7 +3888,7 @@ enum LockErrorKind {
}, },
/// An error that occurs from an invalid lockfile where a wheel comes from a non-wheel source /// An error that occurs from an invalid lockfile where a wheel comes from a non-wheel source
/// such as a directory. /// such as a directory.
#[error("wheels cannot come from {source_type} sources")] #[error("Wheels cannot come from {source_type} sources")]
InvalidWheelSource { InvalidWheelSource {
/// The ID of the distribution that has a missing base. /// The ID of the distribution that has a missing base.
id: PackageId, id: PackageId,
@ -3897,7 +3897,7 @@ enum LockErrorKind {
}, },
/// An error that occurs when a distribution indicates that it is sourced from a remote /// An error that occurs when a distribution indicates that it is sourced from a remote
/// registry, but is missing a URL. /// registry, but is missing a URL.
#[error("found registry distribution {name}=={version} without a valid URL")] #[error("Found registry distribution `{name}=={version}` without a valid URL")]
MissingUrl { MissingUrl {
/// The name of the distribution that is missing a URL. /// The name of the distribution that is missing a URL.
name: PackageName, name: PackageName,
@ -3906,7 +3906,7 @@ enum LockErrorKind {
}, },
/// An error that occurs when a distribution indicates that it is sourced from a local registry, /// An error that occurs when a distribution indicates that it is sourced from a local registry,
/// but is missing a path. /// but is missing a path.
#[error("found registry distribution {name}=={version} without a valid path")] #[error("Found registry distribution `{name}=={version}` without a valid path")]
MissingPath { MissingPath {
/// The name of the distribution that is missing a path. /// The name of the distribution that is missing a path.
name: PackageName, name: PackageName,
@ -3915,34 +3915,34 @@ enum LockErrorKind {
}, },
/// An error that occurs when a distribution indicates that it is sourced from a registry, but /// An error that occurs when a distribution indicates that it is sourced from a registry, but
/// is missing a filename. /// is missing a filename.
#[error("found registry distribution {id} without a valid filename")] #[error("Found registry distribution `{id}` without a valid filename")]
MissingFilename { MissingFilename {
/// The ID of the distribution that is missing a filename. /// The ID of the distribution that is missing a filename.
id: PackageId, id: PackageId,
}, },
/// An error that occurs when a distribution is included with neither wheels nor a source /// An error that occurs when a distribution is included with neither wheels nor a source
/// distribution. /// distribution.
#[error("distribution {id} can't be installed because it doesn't have a source distribution or wheel for the current platform")] #[error("Distribution `{id}` can't be installed because it doesn't have a source distribution or wheel for the current platform")]
NeitherSourceDistNorWheel { NeitherSourceDistNorWheel {
/// The ID of the distribution. /// The ID of the distribution.
id: PackageId, id: PackageId,
}, },
/// An error that occurs when a distribution is marked as both `--no-binary` and `--no-build`. /// An error that occurs when a distribution is marked as both `--no-binary` and `--no-build`.
#[error("distribution {id} can't be installed because it is marked as both `--no-binary` and `--no-build`")] #[error("Distribution `{id}` can't be installed because it is marked as both `--no-binary` and `--no-build`")]
NoBinaryNoBuild { NoBinaryNoBuild {
/// The ID of the distribution. /// The ID of the distribution.
id: PackageId, id: PackageId,
}, },
/// An error that occurs when a distribution is marked as `--no-binary`, but no source /// An error that occurs when a distribution is marked as `--no-binary`, but no source
/// distribution is available. /// distribution is available.
#[error("distribution {id} can't be installed because it is marked as `--no-binary` but has no source distribution")] #[error("Distribution `{id}` can't be installed because it is marked as `--no-binary` but has no source distribution")]
NoBinary { NoBinary {
/// The ID of the distribution. /// The ID of the distribution.
id: PackageId, id: PackageId,
}, },
/// An error that occurs when a distribution is marked as `--no-build`, but no binary /// An error that occurs when a distribution is marked as `--no-build`, but no binary
/// distribution is available. /// distribution is available.
#[error("distribution {id} can't be installed because it is marked as `--no-build` but has no binary distribution")] #[error("Distribution `{id}` can't be installed because it is marked as `--no-build` but has no binary distribution")]
NoBuild { NoBuild {
/// The ID of the distribution. /// The ID of the distribution.
id: PackageId, id: PackageId,
@ -3950,20 +3950,20 @@ enum LockErrorKind {
/// An error that occurs when a wheel-only distribution is incompatible with the current /// An error that occurs when a wheel-only distribution is incompatible with the current
/// platform. /// platform.
#[error( #[error(
"distribution {id} can't be installed because the binary distribution is incompatible with the current platform" "distribution `{id}` can't be installed because the binary distribution is incompatible with the current platform"
)] )]
IncompatibleWheelOnly { IncompatibleWheelOnly {
/// The ID of the distribution. /// The ID of the distribution.
id: PackageId, id: PackageId,
}, },
/// An error that occurs when a wheel-only source is marked as `--no-binary`. /// An error that occurs when a wheel-only source is marked as `--no-binary`.
#[error("distribution {id} can't be installed because it is marked as `--no-binary` but is itself a binary distribution")] #[error("Distribution `{id}` can't be installed because it is marked as `--no-binary` but is itself a binary distribution")]
NoBinaryWheelOnly { NoBinaryWheelOnly {
/// The ID of the distribution. /// The ID of the distribution.
id: PackageId, id: PackageId,
}, },
/// An error that occurs when converting between URLs and paths. /// An error that occurs when converting between URLs and paths.
#[error("found dependency `{id}` with no locked distribution")] #[error("Found dependency `{id}` with no locked distribution")]
VerbatimUrl { VerbatimUrl {
/// The ID of the distribution that has a missing base. /// The ID of the distribution that has a missing base.
id: PackageId, id: PackageId,
@ -3972,14 +3972,14 @@ enum LockErrorKind {
err: VerbatimUrlError, err: VerbatimUrlError,
}, },
/// An error that occurs when parsing an existing requirement. /// An error that occurs when parsing an existing requirement.
#[error("could not compute relative path between workspace and distribution")] #[error("Could not compute relative path between workspace and distribution")]
DistributionRelativePath( DistributionRelativePath(
/// The inner error we forward. /// The inner error we forward.
#[source] #[source]
std::io::Error, std::io::Error,
), ),
/// An error that occurs when converting an index URL to a relative path /// An error that occurs when converting an index URL to a relative path
#[error("could not compute relative path between workspace and index")] #[error("Could not compute relative path between workspace and index")]
IndexRelativePath( IndexRelativePath(
/// The inner error we forward. /// The inner error we forward.
#[source] #[source]
@ -3988,7 +3988,7 @@ enum LockErrorKind {
/// An error that occurs when an ambiguous `package.dependency` is /// An error that occurs when an ambiguous `package.dependency` is
/// missing a `version` field. /// missing a `version` field.
#[error( #[error(
"dependency {name} has missing `version` \ "Dependency `{name}` has missing `version` \
field but has more than one matching package" field but has more than one matching package"
)] )]
MissingDependencyVersion { MissingDependencyVersion {
@ -3998,7 +3998,7 @@ enum LockErrorKind {
/// An error that occurs when an ambiguous `package.dependency` is /// An error that occurs when an ambiguous `package.dependency` is
/// missing a `source` field. /// missing a `source` field.
#[error( #[error(
"dependency {name} has missing `source` \ "Dependency `{name}` has missing `source` \
field but has more than one matching package" field but has more than one matching package"
)] )]
MissingDependencySource { MissingDependencySource {
@ -4006,47 +4006,47 @@ enum LockErrorKind {
name: PackageName, name: PackageName,
}, },
/// An error that occurs when parsing an existing requirement. /// An error that occurs when parsing an existing requirement.
#[error("could not compute relative path between workspace and requirement")] #[error("Could not compute relative path between workspace and requirement")]
RequirementRelativePath( RequirementRelativePath(
/// The inner error we forward. /// The inner error we forward.
#[source] #[source]
std::io::Error, std::io::Error,
), ),
/// An error that occurs when parsing an existing requirement. /// An error that occurs when parsing an existing requirement.
#[error("could not convert between URL and path")] #[error("Could not convert between URL and path")]
RequirementVerbatimUrl( RequirementVerbatimUrl(
/// The inner error we forward. /// The inner error we forward.
#[source] #[source]
VerbatimUrlError, VerbatimUrlError,
), ),
/// An error that occurs when parsing a registry's index URL. /// An error that occurs when parsing a registry's index URL.
#[error("could not convert between URL and path")] #[error("Could not convert between URL and path")]
RegistryVerbatimUrl( RegistryVerbatimUrl(
/// The inner error we forward. /// The inner error we forward.
#[source] #[source]
VerbatimUrlError, VerbatimUrlError,
), ),
/// An error that occurs when converting a path to a URL. /// An error that occurs when converting a path to a URL.
#[error("failed to convert path to URL")] #[error("Failed to convert path to URL")]
PathToUrl, PathToUrl,
/// An error that occurs when converting a URL to a path /// An error that occurs when converting a URL to a path
#[error("failed to convert URL to path")] #[error("Failed to convert URL to path")]
UrlToPath, UrlToPath,
/// An error that occurs when multiple packages with the same /// An error that occurs when multiple packages with the same
/// name were found when identifying the root packages. /// name were found when identifying the root packages.
#[error("found multiple packages matching `{name}`")] #[error("Found multiple packages matching `{name}`")]
MultipleRootPackages { MultipleRootPackages {
/// The ID of the package. /// The ID of the package.
name: PackageName, name: PackageName,
}, },
/// An error that occurs when a root package can't be found. /// An error that occurs when a root package can't be found.
#[error("could not find root package `{name}`")] #[error("Could not find root package `{name}`")]
MissingRootPackage { MissingRootPackage {
/// The ID of the package. /// The ID of the package.
name: PackageName, name: PackageName,
}, },
/// An error that occurs when resolving metadata for a package. /// An error that occurs when resolving metadata for a package.
#[error("failed to generate package metadata for `{id}`")] #[error("Failed to generate package metadata for `{id}`")]
Resolution { Resolution {
/// The ID of the distribution that failed to resolve. /// The ID of the distribution that failed to resolve.
id: PackageId, id: PackageId,
@ -4060,7 +4060,7 @@ enum LockErrorKind {
#[derive(Debug, thiserror::Error)] #[derive(Debug, thiserror::Error)]
enum SourceParseError { enum SourceParseError {
/// An error that occurs when the URL in the source is invalid. /// An error that occurs when the URL in the source is invalid.
#[error("invalid URL in source `{given}`")] #[error("Invalid URL in source `{given}`")]
InvalidUrl { InvalidUrl {
/// The source string given. /// The source string given.
given: String, given: String,
@ -4069,13 +4069,13 @@ enum SourceParseError {
err: url::ParseError, err: url::ParseError,
}, },
/// An error that occurs when a Git URL is missing a precise commit SHA. /// An error that occurs when a Git URL is missing a precise commit SHA.
#[error("missing SHA in source `{given}`")] #[error("Missing SHA in source `{given}`")]
MissingSha { MissingSha {
/// The source string given. /// The source string given.
given: String, given: String,
}, },
/// An error that occurs when a Git URL has an invalid SHA. /// An error that occurs when a Git URL has an invalid SHA.
#[error("invalid SHA in source `{given}`")] #[error("Invalid SHA in source `{given}`")]
InvalidSha { InvalidSha {
/// The source string given. /// The source string given.
given: String, given: String,

View File

@ -6,7 +6,7 @@ Err(
Error { Error {
inner: Error { inner: Error {
inner: TomlError { inner: TomlError {
message: "dependency a has missing `source` field but has more than one matching package", message: "Dependency `a` has missing `source` field but has more than one matching package",
raw: None, raw: None,
keys: [], keys: [],
span: None, span: None,

View File

@ -6,7 +6,7 @@ Err(
Error { Error {
inner: Error { inner: Error {
inner: TomlError { inner: TomlError {
message: "dependency a has missing `version` field but has more than one matching package", message: "Dependency `a` has missing `version` field but has more than one matching package",
raw: None, raw: None,
keys: [], keys: [],
span: None, span: None,

View File

@ -6,7 +6,7 @@ Err(
Error { Error {
inner: Error { inner: Error {
inner: TomlError { inner: TomlError {
message: "dependency a has missing `version` field but has more than one matching package", message: "Dependency `a` has missing `version` field but has more than one matching package",
raw: None, raw: None,
keys: [], keys: [],
span: None, span: None,

View File

@ -1069,7 +1069,7 @@ fn lock_wheel_url() -> Result<()> {
----- stdout ----- ----- stdout -----
----- stderr ----- ----- stderr -----
error: failed to generate package metadata for `anyio==4.3.0 @ direct+https://files.pythonhosted.org/packages/14/fd/2f20c40b45e4fb4324834aea24bd4afdf1143390242c0b33774da0e2e34f/anyio-4.3.0-py3-none-any.whl` error: Failed to generate package metadata for `anyio==4.3.0 @ direct+https://files.pythonhosted.org/packages/14/fd/2f20c40b45e4fb4324834aea24bd4afdf1143390242c0b33774da0e2e34f/anyio-4.3.0-py3-none-any.whl`
Caused by: Network connectivity is disabled, but the requested data wasn't found in the cache for: `https://files.pythonhosted.org/packages/14/fd/2f20c40b45e4fb4324834aea24bd4afdf1143390242c0b33774da0e2e34f/anyio-4.3.0-py3-none-any.whl` Caused by: Network connectivity is disabled, but the requested data wasn't found in the cache for: `https://files.pythonhosted.org/packages/14/fd/2f20c40b45e4fb4324834aea24bd4afdf1143390242c0b33774da0e2e34f/anyio-4.3.0-py3-none-any.whl`
"###); "###);

View File

@ -1214,7 +1214,7 @@ fn no_install_workspace() -> Result<()> {
----- stdout ----- ----- stdout -----
----- stderr ----- ----- stderr -----
error: could not find root package `fake` error: Could not find root package `fake`
"###); "###);
// But we do require the root `pyproject.toml`. // But we do require the root `pyproject.toml`.
@ -1319,9 +1319,9 @@ fn no_install_project_no_build() -> Result<()> {
----- stdout ----- ----- stdout -----
----- stderr ----- ----- stderr -----
warning: Failed to validate existing lockfile: distribution project==0.1.0 @ editable+. can't be installed because it is marked as `--no-build` but has no binary distribution warning: Failed to validate existing lockfile: Distribution `project==0.1.0 @ editable+.` can't be installed because it is marked as `--no-build` but has no binary distribution
Resolved 4 packages in [TIME] Resolved 4 packages in [TIME]
error: distribution project==0.1.0 @ editable+. can't be installed because it is marked as `--no-build` but has no binary distribution error: Distribution `project==0.1.0 @ editable+.` can't be installed because it is marked as `--no-build` but has no binary distribution
"###); "###);
// But it's fine to combine `--no-install-project` with `--no-build`. We shouldn't error, since // But it's fine to combine `--no-install-project` with `--no-build`. We shouldn't error, since
@ -1332,7 +1332,7 @@ fn no_install_project_no_build() -> Result<()> {
----- stdout ----- ----- stdout -----
----- stderr ----- ----- stderr -----
warning: Failed to validate existing lockfile: distribution project==0.1.0 @ editable+. can't be installed because it is marked as `--no-build` but has no binary distribution warning: Failed to validate existing lockfile: Distribution `project==0.1.0 @ editable+.` can't be installed because it is marked as `--no-build` but has no binary distribution
Resolved 4 packages in [TIME] Resolved 4 packages in [TIME]
Prepared 3 packages in [TIME] Prepared 3 packages in [TIME]
Installed 3 packages in [TIME] Installed 3 packages in [TIME]
@ -2224,7 +2224,7 @@ fn no_binary_error() -> Result<()> {
----- stderr ----- ----- stderr -----
Resolved 19 packages in [TIME] Resolved 19 packages in [TIME]
error: distribution django-allauth==0.51.0 @ registry+https://pypi.org/simple can't be installed because it is marked as `--no-build` but has no binary distribution error: Distribution `django-allauth==0.51.0 @ registry+https://pypi.org/simple` can't be installed because it is marked as `--no-build` but has no binary distribution
"###); "###);
assert!(context.temp_dir.child("uv.lock").exists()); assert!(context.temp_dir.child("uv.lock").exists());
@ -2302,7 +2302,7 @@ fn sync_wheel_url_source_error() -> Result<()> {
----- stderr ----- ----- stderr -----
Resolved 3 packages in [TIME] Resolved 3 packages in [TIME]
error: distribution cffi==1.17.1 @ direct+https://files.pythonhosted.org/packages/08/fd/cc2fedbd887223f9f5d170c96e57cbf655df9831a6546c1727ae13fa977a/cffi-1.17.1-cp310-cp310-macosx_11_0_arm64.whl can't be installed because the binary distribution is incompatible with the current platform error: distribution `cffi==1.17.1 @ direct+https://files.pythonhosted.org/packages/08/fd/cc2fedbd887223f9f5d170c96e57cbf655df9831a6546c1727ae13fa977a/cffi-1.17.1-cp310-cp310-macosx_11_0_arm64.whl` can't be installed because the binary distribution is incompatible with the current platform
"###); "###);
Ok(()) Ok(())
@ -2350,7 +2350,7 @@ fn sync_wheel_path_source_error() -> Result<()> {
----- stderr ----- ----- stderr -----
Resolved 3 packages in [TIME] Resolved 3 packages in [TIME]
error: distribution cffi==1.17.1 @ path+cffi-1.17.1-cp310-cp310-macosx_11_0_arm64.whl can't be installed because the binary distribution is incompatible with the current platform error: distribution `cffi==1.17.1 @ path+cffi-1.17.1-cp310-cp310-macosx_11_0_arm64.whl` can't be installed because the binary distribution is incompatible with the current platform
"###); "###);
Ok(()) Ok(())