Running uv lock --check with outdated lockfile will print that --check was passed, instead of --locked (#16322)

Hello,

# Summary

This PR fixes the confusing error message when running `uv lock --check`
with an outdated lockfile.

Previously, the error message incorrectly stated that `--locked` was
provided, even when the user used `--check`.

Now, the error message correctly indicates which flag was used: either
`--check` or `--locked`.

This closes #14105.

# Test plan

- I updated the existing integration test (`check_outdated_lock` in
`lock.rs`) to verify the new error message includes the correct flag.
- I ran existing tests to ensure I have no introduced regressions for
other commands.
This commit is contained in:
Charles-Meldhine Madi Mnemoi 2025-10-21 19:46:10 +02:00 committed by GitHub
parent 509a1e8ff6
commit 225bffbb6c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
15 changed files with 194 additions and 105 deletions

View file

@ -3719,20 +3719,34 @@ pub struct LockArgs {
/// missing or needs to be updated, uv will exit with an error.
///
/// Equivalent to `--locked`.
#[arg(long, alias = "locked", env = EnvVars::UV_LOCKED, value_parser = clap::builder::BoolishValueParser::new(), conflicts_with_all = ["check_exists", "upgrade"])]
#[arg(long, env = EnvVars::UV_LOCKED, value_parser = clap::builder::BoolishValueParser::new(), conflicts_with_all = ["check_exists", "upgrade", "locked"])]
pub check: bool,
/// Check if the lockfile is up-to-date.
///
/// Asserts that the `uv.lock` would remain unchanged after a resolution. If the lockfile is
/// missing or needs to be updated, uv will exit with an error.
///
/// Equivalent to `--check`.
#[arg(long, env = EnvVars::UV_LOCKED, value_parser = clap::builder::BoolishValueParser::new(), conflicts_with_all = ["check_exists", "upgrade", "check"], hide = true)]
pub locked: bool,
/// Assert that a `uv.lock` exists without checking if it is up-to-date.
///
/// Equivalent to `--frozen`.
#[arg(long, alias = "frozen", env = EnvVars::UV_FROZEN, value_parser = clap::builder::BoolishValueParser::new(), conflicts_with = "check")]
#[arg(long, alias = "frozen", env = EnvVars::UV_FROZEN, value_parser = clap::builder::BoolishValueParser::new(), conflicts_with_all = ["check", "locked"])]
pub check_exists: bool,
/// Perform a dry run, without writing the lockfile.
///
/// In dry-run mode, uv will resolve the project's dependencies and report on the resulting
/// changes, but will not write the lockfile to disk.
#[arg(long, conflicts_with = "check_exists", conflicts_with = "check")]
#[arg(
long,
conflicts_with = "check_exists",
conflicts_with = "check",
conflicts_with = "locked"
)]
pub dry_run: bool,
/// Lock the specified Python script, rather than the current project.