Skip to content

Commit

Permalink
Make pip list --editable conflicts with --exlcude-editable
Browse files Browse the repository at this point in the history
  • Loading branch information
j178 committed Jul 27, 2024
1 parent 866d844 commit 567ee3a
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 11 deletions.
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, overrides_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

0 comments on commit 567ee3a

Please sign in to comment.