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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add compatibility arguments for pip list #3055

Merged
merged 2 commits into from
Apr 16, 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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions crates/uv/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1109,6 +1109,9 @@ pub(crate) struct PipListArgs {
/// should be used with caution.
#[clap(long, env = "UV_SYSTEM_PYTHON", group = "discovery")]
pub(crate) system: bool,

#[command(flatten)]
pub(crate) compat_args: compat::PipListCompatArgs,
}

#[derive(Args)]
Expand Down
25 changes: 25 additions & 0 deletions crates/uv/src/compat/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,31 @@ impl CompatArgs for PipCompileCompatArgs {
}
}

/// Arguments for `pip list` compatibility.
///
/// These represent a subset of the `pip list` interface that uv supports by default.
#[derive(Args)]
#[allow(clippy::struct_excessive_bools)]
pub(crate) struct PipListCompatArgs {
#[clap(long, hide = true)]
outdated: bool,
}

impl CompatArgs for crate::compat::PipListCompatArgs {
/// Validate the arguments passed for `pip list` compatibility.
///
/// This method will warn when an argument is passed that has no effect but matches uv's
/// behavior. If an argument is passed that does _not_ match uv's behavior (e.g.,
/// `--outdated`), this method will return an error.
fn validate(&self) -> Result<()> {
if self.outdated {
return Err(anyhow!("pip list's `--outdated` is unsupported."));
}

Ok(())
}
}

/// Arguments for `pip-sync` compatibility.
///
/// These represent a subset of the `pip-sync` interface that uv supports by default.
Expand Down
26 changes: 15 additions & 11 deletions crates/uv/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -454,17 +454,21 @@ async fn run() -> Result<ExitStatus> {
),
Commands::Pip(PipNamespace {
command: PipCommand::List(args),
}) => commands::pip_list(
args.editable,
args.exclude_editable,
&args.exclude,
&args.format,
args.strict,
args.python.as_deref(),
args.system,
&cache,
printer,
),
}) => {
args.compat_args.validate()?;

commands::pip_list(
args.editable,
args.exclude_editable,
&args.exclude,
&args.format,
args.strict,
args.python.as_deref(),
args.system,
&cache,
printer,
)
}
Commands::Pip(PipNamespace {
command: PipCommand::Show(args),
}) => commands::pip_show(
Expand Down