Skip to content

Commit b15d59b

Browse files
Gankrajtfmumm
authored andcommitted
Remove uv version fallback (#14161)
Fixes #14157 --------- Co-authored-by: John Mumm <[email protected]>
1 parent 0eb5b1f commit b15d59b

File tree

3 files changed

+17
-56
lines changed

3 files changed

+17
-56
lines changed

crates/uv/src/commands/project/version.rs

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ use uv_pep440::{BumpCommand, PrereleaseKind, Version};
1919
use uv_pep508::PackageName;
2020
use uv_python::{PythonDownloads, PythonPreference, PythonRequest};
2121
use uv_settings::PythonInstallMirrors;
22-
use uv_warnings::warn_user;
2322
use uv_workspace::pyproject_mut::Error;
2423
use uv_workspace::{
2524
DiscoveryOptions, WorkspaceCache,
@@ -58,7 +57,6 @@ pub(crate) async fn project_version(
5857
mut bump: Vec<VersionBump>,
5958
short: bool,
6059
output_format: VersionFormat,
61-
strict: bool,
6260
project_dir: &Path,
6361
package: Option<PackageName>,
6462
dry_run: bool,
@@ -80,21 +78,7 @@ pub(crate) async fn project_version(
8078
preview: PreviewMode,
8179
) -> Result<ExitStatus> {
8280
// Read the metadata
83-
let project = match find_target(project_dir, package.as_ref()).await {
84-
Ok(target) => target,
85-
Err(err) => {
86-
// If strict, hard bail on failing to find the pyproject.toml
87-
if strict {
88-
return Err(err)?;
89-
}
90-
// Otherwise, warn and provide fallback to the old `uv version` from before 0.7.0
91-
warn_user!(
92-
"Failed to read project metadata ({err}). Running `{}` for compatibility. This fallback will be removed in the future; pass `--preview` to force an error.",
93-
"uv self version".green()
94-
);
95-
return self_version(short, output_format, printer);
96-
}
97-
};
81+
let project = find_target(project_dir, package.as_ref()).await?;
9882

9983
let pyproject_path = project.root().join("pyproject.toml");
10084
let Some(name) = project.project_name().cloned() else {

crates/uv/src/lib.rs

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1059,7 +1059,6 @@ async fn run(mut cli: Cli) -> Result<ExitStatus> {
10591059
}
10601060
Commands::Project(project) => {
10611061
Box::pin(run_project(
1062-
cli.top_level.global_args.project.is_some(),
10631062
project,
10641063
&project_dir,
10651064
run_command,
@@ -1660,7 +1659,6 @@ async fn run(mut cli: Cli) -> Result<ExitStatus> {
16601659

16611660
/// Run a [`ProjectCommand`].
16621661
async fn run_project(
1663-
project_was_explicit: bool,
16641662
project_command: Box<ProjectCommand>,
16651663
project_dir: &Path,
16661664
command: Option<RunCommand>,
@@ -2052,19 +2050,11 @@ async fn run_project(
20522050
.combine(Refresh::from(args.settings.resolver.upgrade.clone())),
20532051
);
20542052

2055-
// If they specified any of these flags, they probably don't mean `uv self version`
2056-
let strict = project_was_explicit
2057-
|| globals.preview.is_enabled()
2058-
|| args.dry_run
2059-
|| !args.bump.is_empty()
2060-
|| args.value.is_some()
2061-
|| args.package.is_some();
20622053
Box::pin(commands::project_version(
20632054
args.value,
20642055
args.bump,
20652056
args.short,
20662057
args.output_format,
2067-
strict,
20682058
project_dir,
20692059
args.package,
20702060
args.dry_run,

crates/uv/tests/it/version.rs

Lines changed: 16 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1437,8 +1437,8 @@ fn version_set_dynamic() -> Result<()> {
14371437
Ok(())
14381438
}
14391439

1440-
// Should fallback to `uv --version` if this pyproject.toml isn't usable for whatever reason
1441-
// (In this case, because tool.uv.managed = false)
1440+
/// Previously would fallback to `uv --version` if this pyproject.toml isn't usable for whatever reason
1441+
/// (In this case, because tool.uv.managed = false)
14421442
#[test]
14431443
fn version_get_fallback_unmanaged() -> Result<()> {
14441444
let context = TestContext::new("3.12");
@@ -1456,13 +1456,12 @@ fn version_get_fallback_unmanaged() -> Result<()> {
14561456
)?;
14571457

14581458
uv_snapshot!(context.filters(), context.version(), @r"
1459-
success: true
1460-
exit_code: 0
1459+
success: false
1460+
exit_code: 2
14611461
----- stdout -----
1462-
uv [VERSION] ([COMMIT] DATE)
14631462
14641463
----- stderr -----
1465-
warning: Failed to read project metadata (The project is marked as unmanaged: `[TEMP_DIR]/`). Running `uv self version` for compatibility. This fallback will be removed in the future; pass `--preview` to force an error.
1464+
error: The project is marked as unmanaged: `[TEMP_DIR]/`
14661465
");
14671466

14681467
let pyproject = fs_err::read_to_string(&pyproject_toml)?;
@@ -1507,13 +1506,12 @@ fn version_get_fallback_unmanaged_short() -> Result<()> {
15071506
.collect::<Vec<_>>();
15081507
uv_snapshot!(filters, context.version()
15091508
.arg("--short"), @r"
1510-
success: true
1511-
exit_code: 0
1509+
success: false
1510+
exit_code: 2
15121511
----- stdout -----
1513-
[VERSION] ([COMMIT] DATE)
15141512
15151513
----- stderr -----
1516-
warning: Failed to read project metadata (The project is marked as unmanaged: `[TEMP_DIR]/`). Running `uv self version` for compatibility. This fallback will be removed in the future; pass `--preview` to force an error.
1514+
error: The project is marked as unmanaged: `[TEMP_DIR]/`
15171515
");
15181516

15191517
let pyproject = fs_err::read_to_string(&pyproject_toml)?;
@@ -1587,25 +1585,14 @@ fn version_get_fallback_unmanaged_json() -> Result<()> {
15871585
.collect::<Vec<_>>();
15881586
if git_version_info_expected() {
15891587
uv_snapshot!(filters, context.version()
1590-
.arg("--output-format").arg("json"), @r#"
1591-
success: true
1592-
exit_code: 0
1593-
----- stdout -----
1594-
{
1595-
"package_name": "uv",
1596-
"version": "[VERSION]",
1597-
"commit_info": {
1598-
"short_commit_hash": "[LONGHASH]",
1599-
"commit_hash": "[LONGHASH]",
1600-
"commit_date": "[DATE]",
1601-
"last_tag": "[TAG]",
1602-
"commits_since_last_tag": [COUNT]
1603-
}
1604-
}
1605-
1606-
----- stderr -----
1607-
warning: Failed to read project metadata (The project is marked as unmanaged: `[TEMP_DIR]/`). Running `uv self version` for compatibility. This fallback will be removed in the future; pass `--preview` to force an error.
1608-
"#);
1588+
.arg("--output-format").arg("json"), @r"
1589+
success: false
1590+
exit_code: 2
1591+
----- stdout -----
1592+
1593+
----- stderr -----
1594+
error: The project is marked as unmanaged: `[TEMP_DIR]/`
1595+
");
16091596
} else {
16101597
uv_snapshot!(filters, context.version()
16111598
.arg("--output-format").arg("json"), @r#"

0 commit comments

Comments
 (0)