From d3651c13f0a25821e486b8d9d09e6f537cb303b0 Mon Sep 17 00:00:00 2001 From: Charlie Marsh Date: Thu, 6 Jun 2024 20:06:05 -0400 Subject: [PATCH] Set `--dev` to default for `uv run` and `uv sync` (#4118) ## Summary Closes https://github.com/astral-sh/uv/issues/4117. --- crates/uv/src/cli.rs | 10 ++++++---- crates/uv/src/settings.rs | 5 ++--- crates/uv/tests/lock.rs | 6 +++--- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/crates/uv/src/cli.rs b/crates/uv/src/cli.rs index 8a911909c..14c5b5ddb 100644 --- a/crates/uv/src/cli.rs +++ b/crates/uv/src/cli.rs @@ -1691,10 +1691,11 @@ pub(crate) struct RunArgs { pub(crate) no_all_extras: bool, /// Include development dependencies. - #[arg(long, overrides_with("no_dev"))] + #[arg(long, overrides_with("no_dev"), hide = true)] pub(crate) dev: bool, - #[arg(long, conflicts_with("offline"), overrides_with("dev"), hide = true)] + /// Omit development dependencies. + #[arg(long, overrides_with("dev"))] pub(crate) no_dev: bool, /// The command to run. @@ -1779,10 +1780,11 @@ pub(crate) struct SyncArgs { pub(crate) no_all_extras: bool, /// Include development dependencies. - #[arg(long, overrides_with("no_dev"))] + #[arg(long, overrides_with("no_dev"), hide = true)] pub(crate) dev: bool, - #[arg(long, conflicts_with("offline"), overrides_with("dev"), hide = true)] + /// Omit development dependencies. + #[arg(long, overrides_with("dev"))] pub(crate) no_dev: bool, /// Refresh all cached data. diff --git a/crates/uv/src/settings.rs b/crates/uv/src/settings.rs index 9211a3ebd..3fdeb37e6 100644 --- a/crates/uv/src/settings.rs +++ b/crates/uv/src/settings.rs @@ -170,7 +170,7 @@ impl RunSettings { flag(all_extras, no_all_extras).unwrap_or_default(), extra.unwrap_or_default(), ), - dev: flag(dev, no_dev).unwrap_or(false), + dev: flag(dev, no_dev).unwrap_or(true), target, args, with, @@ -278,7 +278,7 @@ impl SyncSettings { flag(all_extras, no_all_extras).unwrap_or_default(), extra.unwrap_or_default(), ), - dev: flag(dev, no_dev).unwrap_or(false), + dev: flag(dev, no_dev).unwrap_or(true), python, } } @@ -445,7 +445,6 @@ impl PipCompileSettings { PipOptions { python, system: flag(system, no_system), - index_url: index_args.index_url.and_then(Maybe::into_option), extra_index_url: index_args.extra_index_url.map(|extra_index_urls| { extra_index_urls diff --git a/crates/uv/tests/lock.rs b/crates/uv/tests/lock.rs index a603c6f00..47ea2e848 100644 --- a/crates/uv/tests/lock.rs +++ b/crates/uv/tests/lock.rs @@ -1891,7 +1891,7 @@ fn lock_dev() -> Result<()> { }); // Install from the lockfile, excluding development dependencies. - uv_snapshot!(context.filters(), context.sync(), @r###" + uv_snapshot!(context.filters(), context.sync().arg("--no-dev"), @r###" success: true exit_code: 0 ----- stdout ----- @@ -1904,8 +1904,8 @@ fn lock_dev() -> Result<()> { + project==0.1.0 (from file://[TEMP_DIR]/) "###); - // Install from the lockfile, including development dependencies. - uv_snapshot!(context.filters(), context.sync().arg("--dev"), @r###" + // Install from the lockfile, including development dependencies (the default). + uv_snapshot!(context.filters(), context.sync(), @r###" success: true exit_code: 0 ----- stdout -----