mirror of
https://github.com/astral-sh/uv.git
synced 2025-10-01 06:21:13 +00:00
Make pip list --editable
conflicts with --exlcude-editable
(#5506)
## Summary I think it makes no sense to allow `--editable` and `--exclude-editable` at the same time. ## Test Plan ```console $ cargo run -- pip list --editable --exclude-editable error: the argument '--editable' cannot be used with '--exclude-editable' Usage: uv.exe pip list --editable For more information, try '--help'. ```
This commit is contained in:
parent
866d844977
commit
ae11317cc0
5 changed files with 12 additions and 38 deletions
|
@ -1465,7 +1465,7 @@ pub struct PipListArgs {
|
||||||
pub editable: bool,
|
pub editable: bool,
|
||||||
|
|
||||||
/// Exclude any editable packages from output.
|
/// Exclude any editable packages from output.
|
||||||
#[arg(long)]
|
#[arg(long, conflicts_with = "editable")]
|
||||||
pub exclude_editable: bool,
|
pub exclude_editable: bool,
|
||||||
|
|
||||||
/// Exclude the specified package(s) from the output.
|
/// Exclude the specified package(s) from the output.
|
||||||
|
|
|
@ -24,8 +24,7 @@ use crate::printer::Printer;
|
||||||
/// Enumerate the installed packages in the current environment.
|
/// Enumerate the installed packages in the current environment.
|
||||||
#[allow(clippy::fn_params_excessive_bools)]
|
#[allow(clippy::fn_params_excessive_bools)]
|
||||||
pub(crate) fn pip_list(
|
pub(crate) fn pip_list(
|
||||||
editable: bool,
|
editable: Option<bool>,
|
||||||
exclude_editable: bool,
|
|
||||||
exclude: &[PackageName],
|
exclude: &[PackageName],
|
||||||
format: &ListFormat,
|
format: &ListFormat,
|
||||||
strict: bool,
|
strict: bool,
|
||||||
|
@ -54,9 +53,7 @@ pub(crate) fn pip_list(
|
||||||
// Filter if `--editable` is specified; always sort by name.
|
// Filter if `--editable` is specified; always sort by name.
|
||||||
let results = site_packages
|
let results = site_packages
|
||||||
.iter()
|
.iter()
|
||||||
.filter(|dist| {
|
.filter(|dist| editable.is_none() || editable == Some(dist.is_editable()))
|
||||||
(!dist.is_editable() && !editable) || (dist.is_editable() && !exclude_editable)
|
|
||||||
})
|
|
||||||
.filter(|dist| !exclude.contains(dist.name()))
|
.filter(|dist| !exclude.contains(dist.name()))
|
||||||
.sorted_unstable_by(|a, b| a.name().cmp(b.name()).then(a.version().cmp(b.version())))
|
.sorted_unstable_by(|a, b| a.name().cmp(b.name()).then(a.version().cmp(b.version())))
|
||||||
.collect_vec();
|
.collect_vec();
|
||||||
|
|
|
@ -465,7 +465,6 @@ async fn run(cli: Cli) -> Result<ExitStatus> {
|
||||||
|
|
||||||
commands::pip_list(
|
commands::pip_list(
|
||||||
args.editable,
|
args.editable,
|
||||||
args.exclude_editable,
|
|
||||||
&args.exclude,
|
&args.exclude,
|
||||||
&args.format,
|
&args.format,
|
||||||
args.settings.strict,
|
args.settings.strict,
|
||||||
|
|
|
@ -1240,8 +1240,7 @@ impl PipFreezeSettings {
|
||||||
#[allow(clippy::struct_excessive_bools)]
|
#[allow(clippy::struct_excessive_bools)]
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
pub(crate) struct PipListSettings {
|
pub(crate) struct PipListSettings {
|
||||||
pub(crate) editable: bool,
|
pub(crate) editable: Option<bool>,
|
||||||
pub(crate) exclude_editable: bool,
|
|
||||||
pub(crate) exclude: Vec<PackageName>,
|
pub(crate) exclude: Vec<PackageName>,
|
||||||
pub(crate) format: ListFormat,
|
pub(crate) format: ListFormat,
|
||||||
pub(crate) settings: PipSettings,
|
pub(crate) settings: PipSettings,
|
||||||
|
@ -1264,8 +1263,7 @@ impl PipListSettings {
|
||||||
} = args;
|
} = args;
|
||||||
|
|
||||||
Self {
|
Self {
|
||||||
editable,
|
editable: flag(editable, exclude_editable),
|
||||||
exclude_editable,
|
|
||||||
exclude,
|
exclude,
|
||||||
format,
|
format,
|
||||||
settings: PipSettings::combine(
|
settings: PipSettings::combine(
|
||||||
|
|
|
@ -213,11 +213,16 @@ fn list_editable_only() {
|
||||||
uv_snapshot!(filters, list_command(&context)
|
uv_snapshot!(filters, list_command(&context)
|
||||||
.arg("--editable")
|
.arg("--editable")
|
||||||
.arg("--exclude-editable"), @r###"
|
.arg("--exclude-editable"), @r###"
|
||||||
success: true
|
success: false
|
||||||
exit_code: 0
|
exit_code: 2
|
||||||
----- stdout -----
|
----- stdout -----
|
||||||
|
|
||||||
----- stderr -----
|
----- 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'.
|
||||||
"###
|
"###
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -367,19 +372,6 @@ fn list_format_json() {
|
||||||
----- stderr -----
|
----- stderr -----
|
||||||
"###
|
"###
|
||||||
);
|
);
|
||||||
|
|
||||||
uv_snapshot!(filters, list_command(&context)
|
|
||||||
.arg("--format=json")
|
|
||||||
.arg("--editable")
|
|
||||||
.arg("--exclude-editable"), @r###"
|
|
||||||
success: true
|
|
||||||
exit_code: 0
|
|
||||||
----- stdout -----
|
|
||||||
[]
|
|
||||||
|
|
||||||
----- stderr -----
|
|
||||||
"###
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -451,18 +443,6 @@ fn list_format_freeze() {
|
||||||
----- stderr -----
|
----- stderr -----
|
||||||
"###
|
"###
|
||||||
);
|
);
|
||||||
|
|
||||||
uv_snapshot!(filters, list_command(&context)
|
|
||||||
.arg("--format=freeze")
|
|
||||||
.arg("--editable")
|
|
||||||
.arg("--exclude-editable"), @r###"
|
|
||||||
success: true
|
|
||||||
exit_code: 0
|
|
||||||
----- stdout -----
|
|
||||||
|
|
||||||
----- stderr -----
|
|
||||||
"###
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue