Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make pip list --editable conflicts with --exlcude-editable #5506

Merged
merged 2 commits into from
Jul 27, 2024
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
2 changes: 1 addition & 1 deletion crates/uv-cli/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1465,7 +1465,7 @@ pub struct PipListArgs {
pub editable: bool,

/// Exclude any editable packages from output.
#[arg(long)]
#[arg(long, conflicts_with = "editable")]
pub exclude_editable: bool,

/// Exclude the specified package(s) from the output.
Expand Down
7 changes: 2 additions & 5 deletions crates/uv/src/commands/pip/list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ use crate::printer::Printer;
/// Enumerate the installed packages in the current environment.
#[allow(clippy::fn_params_excessive_bools)]
pub(crate) fn pip_list(
editable: bool,
exclude_editable: bool,
editable: Option<bool>,
exclude: &[PackageName],
format: &ListFormat,
strict: bool,
Expand Down Expand Up @@ -54,9 +53,7 @@ pub(crate) fn pip_list(
// Filter if `--editable` is specified; always sort by name.
let results = site_packages
.iter()
.filter(|dist| {
(!dist.is_editable() && !editable) || (dist.is_editable() && !exclude_editable)
})
.filter(|dist| editable.is_none() || editable == Some(dist.is_editable()))
.filter(|dist| !exclude.contains(dist.name()))
.sorted_unstable_by(|a, b| a.name().cmp(b.name()).then(a.version().cmp(b.version())))
.collect_vec();
Expand Down
1 change: 0 additions & 1 deletion crates/uv/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,6 @@ async fn run(cli: Cli) -> Result<ExitStatus> {

commands::pip_list(
args.editable,
args.exclude_editable,
&args.exclude,
&args.format,
args.settings.strict,
Expand Down
6 changes: 2 additions & 4 deletions crates/uv/src/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1240,8 +1240,7 @@ impl PipFreezeSettings {
#[allow(clippy::struct_excessive_bools)]
#[derive(Debug, Clone)]
pub(crate) struct PipListSettings {
pub(crate) editable: bool,
pub(crate) exclude_editable: bool,
pub(crate) editable: Option<bool>,
pub(crate) exclude: Vec<PackageName>,
pub(crate) format: ListFormat,
pub(crate) settings: PipSettings,
Expand All @@ -1264,8 +1263,7 @@ impl PipListSettings {
} = args;

Self {
editable,
exclude_editable,
editable: flag(editable, exclude_editable),
exclude,
format,
settings: PipSettings::combine(
Expand Down
34 changes: 7 additions & 27 deletions crates/uv/tests/pip_list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -213,11 +213,16 @@ fn list_editable_only() {
uv_snapshot!(filters, list_command(&context)
.arg("--editable")
.arg("--exclude-editable"), @r###"
success: true
exit_code: 0
success: false
exit_code: 2
----- stdout -----

----- stderr -----
error: the argument '--editable' cannot be used with '--exclude-editable'

Usage: uv pip list --cache-dir [CACHE_DIR] --editable

For more information, try '--help'.
"###
);
}
Expand Down Expand Up @@ -367,19 +372,6 @@ fn list_format_json() {
----- stderr -----
"###
);

uv_snapshot!(filters, list_command(&context)
.arg("--format=json")
.arg("--editable")
.arg("--exclude-editable"), @r###"
success: true
exit_code: 0
----- stdout -----
[]

----- stderr -----
"###
);
}

#[test]
Expand Down Expand Up @@ -451,18 +443,6 @@ fn list_format_freeze() {
----- stderr -----
"###
);

uv_snapshot!(filters, list_command(&context)
.arg("--format=freeze")
.arg("--editable")
.arg("--exclude-editable"), @r###"
success: true
exit_code: 0
----- stdout -----

----- stderr -----
"###
);
}

#[test]
Expand Down
Loading