Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions crates/uv-cli/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3077,15 +3077,15 @@ pub struct RunArgs {
/// Optional dependencies are defined via `project.optional-dependencies` in a `pyproject.toml`.
///
/// This option is only available when running in a project.
#[arg(long, conflicts_with = "all_extras", value_parser = extra_name_with_clap_error)]
#[arg(long, conflicts_with = "all_extras", conflicts_with = "only_group", value_parser = extra_name_with_clap_error)]
pub extra: Option<Vec<ExtraName>>,

/// Include all optional dependencies.
///
/// Optional dependencies are defined via `project.optional-dependencies` in a `pyproject.toml`.
///
/// This option is only available when running in a project.
#[arg(long, conflicts_with = "extra")]
#[arg(long, conflicts_with = "extra", conflicts_with = "only_group")]
pub all_extras: bool,

/// Exclude the specified optional dependencies, if `--all-extras` is supplied.
Expand Down Expand Up @@ -3396,7 +3396,7 @@ pub struct SyncArgs {
///
/// Note that all optional dependencies are always included in the resolution; this option only
/// affects the selection of packages to install.
#[arg(long, conflicts_with = "all_extras", value_parser = extra_name_with_clap_error)]
#[arg(long, conflicts_with = "all_extras", conflicts_with = "only_group", value_parser = extra_name_with_clap_error)]
pub extra: Option<Vec<ExtraName>>,

/// Select the output format.
Expand All @@ -3410,7 +3410,7 @@ pub struct SyncArgs {
///
/// Note that all optional dependencies are always included in the resolution; this option only
/// affects the selection of packages to install.
#[arg(long, conflicts_with = "extra")]
#[arg(long, conflicts_with = "extra", conflicts_with = "only_group")]
pub all_extras: bool,

/// Exclude the specified optional dependencies, if `--all-extras` is supplied.
Expand Down Expand Up @@ -4247,11 +4247,11 @@ pub struct ExportArgs {
/// Include optional dependencies from the specified extra name.
///
/// May be provided more than once.
#[arg(long, conflicts_with = "all_extras", value_parser = extra_name_with_clap_error)]
#[arg(long, conflicts_with = "all_extras", conflicts_with = "only_group", value_parser = extra_name_with_clap_error)]
pub extra: Option<Vec<ExtraName>>,

/// Include all optional dependencies.
#[arg(long, conflicts_with = "extra")]
#[arg(long, conflicts_with = "extra", conflicts_with = "only_group")]
pub all_extras: bool,

/// Exclude the specified optional dependencies, if `--all-extras` is supplied.
Expand Down
52 changes: 52 additions & 0 deletions crates/uv/tests/it/export.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4467,3 +4467,55 @@ fn no_editable_env_var() -> Result<()> {

Ok(())
}

#[test]
fn export_only_group_and_extra_conflict() -> Result<()> {
let context = TestContext::new("3.12");

let pyproject_toml = context.temp_dir.child("pyproject.toml");
pyproject_toml.write_str(
r#"
[project]
name = "project"
version = "0.1.0"
requires-python = ">=3.12"
dependencies = []

[project.optional-dependencies]
test = ["pytest"]

[dependency-groups]
dev = ["ruff"]
"#,
)?;

// Using --only-group and --extra together should error.
uv_snapshot!(context.filters(), context.export().arg("--only-group").arg("dev").arg("--extra").arg("test"), @r###"
success: false
exit_code: 2
----- stdout -----

----- stderr -----
error: the argument '--only-group <ONLY_GROUP>' cannot be used with '--extra <EXTRA>'

Usage: uv export --cache-dir [CACHE_DIR] --only-group <ONLY_GROUP> --exclude-newer <EXCLUDE_NEWER>

For more information, try '--help'.
"###);

// Using --only-group and --all-extras together should also error.
uv_snapshot!(context.filters(), context.export().arg("--only-group").arg("dev").arg("--all-extras"), @r###"
success: false
exit_code: 2
----- stdout -----

----- stderr -----
error: the argument '--only-group <ONLY_GROUP>' cannot be used with '--all-extras'

Usage: uv export --cache-dir [CACHE_DIR] --only-group <ONLY_GROUP> --exclude-newer <EXCLUDE_NEWER>

For more information, try '--help'.
"###);

Ok(())
}
52 changes: 52 additions & 0 deletions crates/uv/tests/it/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6039,3 +6039,55 @@ fn isolate_child_environment() -> Result<()> {

Ok(())
}

#[test]
fn run_only_group_and_extra_conflict() -> Result<()> {
let context = TestContext::new("3.12");

let pyproject_toml = context.temp_dir.child("pyproject.toml");
pyproject_toml.write_str(
r#"
[project]
name = "project"
version = "0.1.0"
requires-python = ">=3.12"
dependencies = []

[project.optional-dependencies]
test = ["pytest"]

[dependency-groups]
dev = ["ruff"]
"#,
)?;

// Using --only-group and --extra together should error.
uv_snapshot!(context.filters(), context.run().arg("--only-group").arg("dev").arg("--extra").arg("test").arg("python").arg("-c").arg("print('hello')"), @r###"
success: false
exit_code: 2
----- stdout -----

----- stderr -----
error: the argument '--only-group <ONLY_GROUP>' cannot be used with '--extra <EXTRA>'

Usage: uv run --cache-dir [CACHE_DIR] --only-group <ONLY_GROUP> --exclude-newer <EXCLUDE_NEWER>

For more information, try '--help'.
"###);

// Using --only-group and --all-extras together should also error.
uv_snapshot!(context.filters(), context.run().arg("--only-group").arg("dev").arg("--all-extras").arg("python").arg("-c").arg("print('hello')"), @r###"
success: false
exit_code: 2
----- stdout -----

----- stderr -----
error: the argument '--only-group <ONLY_GROUP>' cannot be used with '--all-extras'

Usage: uv run --cache-dir [CACHE_DIR] --only-group <ONLY_GROUP> --exclude-newer <EXCLUDE_NEWER>

For more information, try '--help'.
"###);

Ok(())
}
52 changes: 52 additions & 0 deletions crates/uv/tests/it/sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14093,3 +14093,55 @@ fn workspace_editable_conflict() -> Result<()> {

Ok(())
}

#[test]
fn only_group_and_extra_conflict() -> Result<()> {
let context = TestContext::new("3.12");

let pyproject_toml = context.temp_dir.child("pyproject.toml");
pyproject_toml.write_str(
r#"
[project]
name = "project"
version = "0.1.0"
requires-python = ">=3.12"
dependencies = []

[project.optional-dependencies]
test = ["pytest"]

[dependency-groups]
dev = ["ruff"]
"#,
)?;

// Using --only-group and --extra together should error.
uv_snapshot!(context.filters(), context.sync().arg("--only-group").arg("dev").arg("--extra").arg("test"), @r###"
success: false
exit_code: 2
----- stdout -----

----- stderr -----
error: the argument '--only-group <ONLY_GROUP>' cannot be used with '--extra <EXTRA>'

Usage: uv sync --cache-dir [CACHE_DIR] --only-group <ONLY_GROUP> --exclude-newer <EXCLUDE_NEWER>

For more information, try '--help'.
"###);

// Using --only-group and --all-extras together should also error.
uv_snapshot!(context.filters(), context.sync().arg("--only-group").arg("dev").arg("--all-extras"), @r###"
success: false
exit_code: 2
----- stdout -----

----- stderr -----
error: the argument '--only-group <ONLY_GROUP>' cannot be used with '--all-extras'

Usage: uv sync --cache-dir [CACHE_DIR] --only-group <ONLY_GROUP> --exclude-newer <EXCLUDE_NEWER>

For more information, try '--help'.
"###);

Ok(())
}
Loading