Skip to content

Commit

Permalink
fix handling of --all-groups and --no-default-groups flags (#11224)
Browse files Browse the repository at this point in the history
This is a rewrite of the groups subsystem to have more clear semantics,
and some adjustments to the CLI flag constraints. In doing so, the
following bugs are fixed:

* `--no-default-groups --no-group foo` is no longer needlessly rejected
* `--all-groups --no-default-groups` now correctly evaluates to
`--all-groups` where previously it was erroneously being interpretted as
just `--no-default-groups`
* `--all-groups --only-dev` is now illegal, where previously it was
accepted and mishandled, as if it was a mythical `--only-all-groups`
flag

Fixes #10890
Closes #10891
  • Loading branch information
Gankra authored Feb 5, 2025
1 parent 311a96b commit 72d9361
Show file tree
Hide file tree
Showing 12 changed files with 1,171 additions and 578 deletions.
40 changes: 20 additions & 20 deletions crates/uv-cli/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2702,7 +2702,7 @@ pub struct RunArgs {
/// Include dependencies from the specified dependency group.
///
/// May be provided multiple times.
#[arg(long, conflicts_with("only_group"))]
#[arg(long, conflicts_with_all = ["only_group", "only_dev"])]
pub group: Vec<GroupName>,

/// Exclude dependencies from the specified dependency group.
Expand All @@ -2714,21 +2714,21 @@ pub struct RunArgs {
/// Exclude dependencies from default groups.
///
/// `--group` can be used to include specific groups.
#[arg(long, conflicts_with_all = ["no_group", "only_group"])]
#[arg(long)]
pub no_default_groups: bool,

/// Only include dependencies from the specified dependency group.
///
/// The project itself will also be omitted.
///
/// May be provided multiple times.
#[arg(long, conflicts_with("group"))]
#[arg(long, conflicts_with_all = ["group", "dev", "all_groups"])]
pub only_group: Vec<GroupName>,

/// Include dependencies from all dependency groups.
///
/// `--no-group` can be used to exclude specific groups.
#[arg(long, conflicts_with_all = [ "group", "only_group" ])]
#[arg(long, conflicts_with_all = ["only_group", "only_dev"])]
pub all_groups: bool,

/// Run a Python module.
Expand All @@ -2742,7 +2742,7 @@ pub struct RunArgs {
/// Omit other dependencies. The project itself will also be omitted.
///
/// This option is an alias for `--only-group dev`.
#[arg(long, conflicts_with("no_dev"))]
#[arg(long, conflicts_with_all = ["group", "all_groups", "no_dev"])]
pub only_dev: bool,

/// Install any editable dependencies, including the project and any workspace members, as
Expand Down Expand Up @@ -2974,7 +2974,7 @@ pub struct SyncArgs {
/// Omit other dependencies. The project itself will also be omitted.
///
/// This option is an alias for `--only-group dev`.
#[arg(long, conflicts_with("no_dev"))]
#[arg(long, conflicts_with_all = ["group", "all_groups", "no_dev"])]
pub only_dev: bool,

/// Include dependencies from the specified dependency group.
Expand All @@ -2983,7 +2983,7 @@ pub struct SyncArgs {
/// `tool.uv.conflicts`, uv will report an error.
///
/// May be provided multiple times.
#[arg(long, conflicts_with("only_group"))]
#[arg(long, conflicts_with_all = ["only_group", "only_dev"])]
pub group: Vec<GroupName>,

/// Exclude dependencies from the specified dependency group.
Expand All @@ -2995,21 +2995,21 @@ pub struct SyncArgs {
/// Exclude dependencies from default groups.
///
/// `--group` can be used to include specific groups.
#[arg(long, conflicts_with_all = ["no_group", "only_group"])]
#[arg(long)]
pub no_default_groups: bool,

/// Only include dependencies from the specified dependency group.
///
/// The project itself will also be omitted.
///
/// May be provided multiple times.
#[arg(long, conflicts_with("group"))]
#[arg(long, conflicts_with_all = ["group", "dev", "all_groups"])]
pub only_group: Vec<GroupName>,

/// Include dependencies from all dependency groups.
///
/// `--no-group` can be used to exclude specific groups.
#[arg(long, conflicts_with_all = [ "group", "only_group" ])]
#[arg(long, conflicts_with_all = ["only_group", "only_dev"])]
pub all_groups: bool,

/// Install any editable dependencies, including the project and any workspace members, as
Expand Down Expand Up @@ -3452,7 +3452,7 @@ pub struct TreeArgs {
/// Omit other dependencies. The project itself will also be omitted.
///
/// This option is an alias for `--only-group dev`.
#[arg(long, conflicts_with("no_dev"))]
#[arg(long, conflicts_with_all = ["group", "all_groups", "no_dev"])]
pub only_dev: bool,

/// Omit the development dependency group.
Expand All @@ -3464,7 +3464,7 @@ pub struct TreeArgs {
/// Include dependencies from the specified dependency group.
///
/// May be provided multiple times.
#[arg(long, conflicts_with("only_group"))]
#[arg(long, conflicts_with_all = ["only_group", "only_dev"])]
pub group: Vec<GroupName>,

/// Exclude dependencies from the specified dependency group.
Expand All @@ -3476,21 +3476,21 @@ pub struct TreeArgs {
/// Exclude dependencies from default groups.
///
/// `--group` can be used to include specific groups.
#[arg(long, conflicts_with_all = ["no_group", "only_group"])]
#[arg(long)]
pub no_default_groups: bool,

/// Only include dependencies from the specified dependency group.
///
/// The project itself will also be omitted.
///
/// May be provided multiple times.
#[arg(long, conflicts_with("group"))]
#[arg(long, conflicts_with_all = ["group", "dev", "all_groups"])]
pub only_group: Vec<GroupName>,

/// Include dependencies from all dependency groups.
///
/// `--no-group` can be used to exclude specific groups.
#[arg(long, conflicts_with_all = [ "group", "only_group" ])]
#[arg(long, conflicts_with_all = ["only_group", "only_dev"])]
pub all_groups: bool,

/// Assert that the `uv.lock` will remain unchanged.
Expand Down Expand Up @@ -3626,13 +3626,13 @@ pub struct ExportArgs {
/// Omit other dependencies. The project itself will also be omitted.
///
/// This option is an alias for `--only-group dev`.
#[arg(long, conflicts_with("no_dev"))]
#[arg(long, conflicts_with_all = ["group", "all_groups", "no_dev"])]
pub only_dev: bool,

/// Include dependencies from the specified dependency group.
///
/// May be provided multiple times.
#[arg(long, conflicts_with("only_group"))]
#[arg(long, conflicts_with_all = ["only_group", "only_dev"])]
pub group: Vec<GroupName>,

/// Exclude dependencies from the specified dependency group.
Expand All @@ -3644,21 +3644,21 @@ pub struct ExportArgs {
/// Exclude dependencies from default groups.
///
/// `--group` can be used to include specific groups.
#[arg(long, conflicts_with_all = ["no_group", "only_group"])]
#[arg(long)]
pub no_default_groups: bool,

/// Only include dependencies from the specified dependency group.
///
/// The project itself will also be omitted.
///
/// May be provided multiple times.
#[arg(long, conflicts_with("group"))]
#[arg(long, conflicts_with_all = ["group", "dev", "all_groups"])]
pub only_group: Vec<GroupName>,

/// Include dependencies from all dependency groups.
///
/// `--no-group` can be used to exclude specific groups.
#[arg(long, conflicts_with_all = [ "group", "only_group" ])]
#[arg(long, conflicts_with_all = ["only_group", "only_dev"])]
pub all_groups: bool,

/// Exclude the comment header at the top of the generated output file.
Expand Down
Loading

0 comments on commit 72d9361

Please sign in to comment.