Include versions in the lockfile coherence error message (#12249)

This commit is contained in:
Zanie Blue 2025-03-17 17:34:51 -05:00 committed by GitHub
parent 0c352c68e9
commit dfa5eed5ef
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 9 additions and 3 deletions

View File

@ -2877,6 +2877,8 @@ impl PackageWire {
if version != &wheel.filename.version {
return Err(LockError::from(LockErrorKind::InconsistentVersions {
name: self.id.name,
version: version.clone(),
wheel: wheel.clone(),
}));
}
}
@ -5171,10 +5173,14 @@ enum LockErrorKind {
},
/// A package has inconsistent versions in a single entry
// Using name instead of id since the version in the id is part of the conflict.
#[error("Locked package and file versions are inconsistent for `{name}`", name = name.cyan())]
#[error("The entry for package `{name}` v{version} has wheel `{wheel_filename}` with inconsistent version: v{wheel_version} ", name = name.cyan(), wheel_filename = wheel.filename, wheel_version = wheel.filename.version)]
InconsistentVersions {
/// The name of the package with the inconsistent entry.
name: PackageName,
/// The version of the package with the inconsistent entry.
version: Version,
/// The wheel with the inconsistent version.
wheel: Wheel,
},
#[error(
"Found conflicting extras `{package1}[{extra1}]` \

View File

@ -8549,7 +8549,7 @@ fn locked_version_coherence() -> Result<()> {
----- stderr -----
error: Failed to parse `uv.lock`
Caused by: Locked package and file versions are inconsistent for `iniconfig`
Caused by: The entry for package `iniconfig` v1.0.0 has wheel `iniconfig-2.0.0-py3-none-any.whl` with inconsistent version: v2.0.0
");
// Without `--locked`, we could fail or recreate the lockfile, currently, we fail.
@ -8560,7 +8560,7 @@ fn locked_version_coherence() -> Result<()> {
----- stderr -----
error: Failed to parse `uv.lock`
Caused by: Locked package and file versions are inconsistent for `iniconfig`
Caused by: The entry for package `iniconfig` v1.0.0 has wheel `iniconfig-2.0.0-py3-none-any.whl` with inconsistent version: v2.0.0
");
Ok(())