mirror of
https://github.com/astral-sh/uv.git
synced 2025-10-01 14:31:12 +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,
|
||||
|
||||
/// 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.
|
||||
|
|
|
@ -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,
|
||||
|
@ -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();
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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,
|
||||
|
@ -1264,8 +1263,7 @@ impl PipListSettings {
|
|||
} = args;
|
||||
|
||||
Self {
|
||||
editable,
|
||||
exclude_editable,
|
||||
editable: flag(editable, exclude_editable),
|
||||
exclude,
|
||||
format,
|
||||
settings: PipSettings::combine(
|
||||
|
|
|
@ -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'.
|
||||
"###
|
||||
);
|
||||
}
|
||||
|
@ -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]
|
||||
|
@ -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]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue