Skip to content

Commit 753329f

Browse files
committed
restore the prior @latest error message
1 parent 5ac5190 commit 753329f

2 files changed

Lines changed: 12 additions & 3 deletions

File tree

crates/uv-python/src/discovery.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,10 @@ pub enum Error {
238238
#[error("Invalid version request: {0}")]
239239
InvalidVersionRequest(String),
240240

241+
/// An invalid version request was given
242+
#[error("Requesting the 'latest' Python version is not yet supported")]
243+
LatestVersionRequest,
244+
241245
// TODO(zanieb): Is this error case necessary still? We should probably drop it.
242246
#[error("Interpreter discovery for `{0}` requires `{1}` but only `{2}` is allowed")]
243247
SourceNotAllowed(PythonRequest, PythonSource, PythonPreference),
@@ -1578,6 +1582,11 @@ impl PythonRequest {
15781582
// The @ separator is optional. If it's present, the right half must be a version, and
15791583
// parsing errors are raised to the caller.
15801584
if let Some(after_at) = rest.strip_prefix('@') {
1585+
if after_at == "latest" {
1586+
// Handle `@latest` as a special case. It's still an error for now, but we plan to
1587+
// support it. TODO(zanieb): Add `PythonRequest::Latest`
1588+
return Err(Error::LatestVersionRequest);
1589+
}
15811590
return after_at.parse().map(Some);
15821591
}
15831592
// The @ was not present, so if the version fails to parse just return Ok(None). For

crates/uv/tests/it/tool_run.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2039,14 +2039,14 @@ fn tool_run_python_at_version() {
20392039
// Request `@latest` (not yet supported)
20402040
uv_snapshot!(context.filters(), context.tool_run()
20412041
.arg("python@latest")
2042-
.arg("--version"), @r"
2042+
.arg("--version"), @r###"
20432043
success: false
20442044
exit_code: 2
20452045
----- stdout -----
20462046
20472047
----- stderr -----
2048-
error: Invalid version request: latest
2049-
");
2048+
error: Requesting the 'latest' Python version is not yet supported
2049+
"###);
20502050
}
20512051

20522052
#[test]

0 commit comments

Comments
 (0)