mirror of
https://github.com/astral-sh/uv.git
synced 2025-07-07 13:25:00 +00:00
Add --disable-pip-version-check
to compatibility arguments (#4672)
## Summary Closes https://github.com/astral-sh/uv/issues/4590.
This commit is contained in:
parent
d5501274d8
commit
8ea47ab45f
3 changed files with 59 additions and 3 deletions
|
@ -176,19 +176,26 @@ impl CompatArgs for PipCompileCompatArgs {
|
|||
#[derive(Args)]
|
||||
#[allow(clippy::struct_excessive_bools)]
|
||||
pub struct PipListCompatArgs {
|
||||
#[clap(long, hide = true)]
|
||||
disable_pip_version_check: bool,
|
||||
|
||||
#[clap(long, hide = true)]
|
||||
outdated: bool,
|
||||
}
|
||||
|
||||
impl CompatArgs for crate::compat::PipListCompatArgs {
|
||||
impl CompatArgs for 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.disable_pip_version_check {
|
||||
warn_user!("pip's `--disable-pip-version-check` has no effect.");
|
||||
}
|
||||
|
||||
if self.outdated {
|
||||
return Err(anyhow!("pip list's `--outdated` is unsupported."));
|
||||
return Err(anyhow!("pip's `--outdated` is unsupported."));
|
||||
}
|
||||
|
||||
Ok(())
|
||||
|
@ -359,6 +366,9 @@ impl CompatArgs for VenvCompatArgs {
|
|||
#[derive(Args)]
|
||||
#[allow(clippy::struct_excessive_bools)]
|
||||
pub struct PipInstallCompatArgs {
|
||||
#[clap(long, hide = true)]
|
||||
disable_pip_version_check: bool,
|
||||
|
||||
#[clap(long, hide = false)]
|
||||
user: bool,
|
||||
}
|
||||
|
@ -370,11 +380,41 @@ impl CompatArgs for PipInstallCompatArgs {
|
|||
/// behavior. If an argument is passed that does _not_ match uv's behavior, this method will
|
||||
/// return an error.
|
||||
fn validate(&self) -> Result<()> {
|
||||
if self.disable_pip_version_check {
|
||||
warn_user!("pip's `--disable-pip-version-check` has no effect.");
|
||||
}
|
||||
|
||||
if self.user {
|
||||
return Err(anyhow!(
|
||||
"pip install's `--user` is unsupported (use a virtual environment instead)."
|
||||
"pip's `--user` is unsupported (use a virtual environment instead)."
|
||||
));
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
/// Arguments for generic `pip` command compatibility.
|
||||
///
|
||||
/// These represent a subset of the `pip` interface that exists on all commands.
|
||||
#[derive(Args)]
|
||||
#[allow(clippy::struct_excessive_bools)]
|
||||
pub struct PipGlobalCompatArgs {
|
||||
#[clap(long, hide = true)]
|
||||
disable_pip_version_check: bool,
|
||||
}
|
||||
|
||||
impl CompatArgs for PipGlobalCompatArgs {
|
||||
/// Validate the arguments passed for `pip` 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, this method will
|
||||
/// return an error.
|
||||
fn validate(&self) -> Result<()> {
|
||||
if self.disable_pip_version_check {
|
||||
warn_user!("pip's `--disable-pip-version-check` has no effect.");
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1205,6 +1205,9 @@ pub struct PipUninstallArgs {
|
|||
/// Uninstall packages from the specified `--prefix` directory.
|
||||
#[arg(long, conflicts_with = "target")]
|
||||
pub prefix: Option<PathBuf>,
|
||||
|
||||
#[command(flatten)]
|
||||
pub compat_args: compat::PipGlobalCompatArgs,
|
||||
}
|
||||
|
||||
#[derive(Args)]
|
||||
|
@ -1255,6 +1258,9 @@ pub struct PipFreezeArgs {
|
|||
|
||||
#[arg(long, overrides_with("system"), hide = true)]
|
||||
pub no_system: bool,
|
||||
|
||||
#[command(flatten)]
|
||||
pub compat_args: compat::PipGlobalCompatArgs,
|
||||
}
|
||||
|
||||
#[derive(Args)]
|
||||
|
@ -1407,6 +1413,9 @@ pub struct PipShowArgs {
|
|||
|
||||
#[arg(long, overrides_with("system"), hide = true)]
|
||||
pub no_system: bool,
|
||||
|
||||
#[command(flatten)]
|
||||
pub compat_args: compat::PipGlobalCompatArgs,
|
||||
}
|
||||
|
||||
#[derive(Args)]
|
||||
|
@ -1468,6 +1477,9 @@ pub struct PipTreeArgs {
|
|||
|
||||
#[arg(long, overrides_with("system"))]
|
||||
pub no_system: bool,
|
||||
|
||||
#[command(flatten)]
|
||||
pub compat_args: compat::PipGlobalCompatArgs,
|
||||
}
|
||||
|
||||
#[derive(Args)]
|
||||
|
|
|
@ -921,6 +921,7 @@ impl PipUninstallSettings {
|
|||
no_break_system_packages,
|
||||
target,
|
||||
prefix,
|
||||
compat_args: _,
|
||||
} = args;
|
||||
|
||||
Self {
|
||||
|
@ -960,6 +961,7 @@ impl PipFreezeSettings {
|
|||
python,
|
||||
system,
|
||||
no_system,
|
||||
compat_args: _,
|
||||
} = args;
|
||||
|
||||
Self {
|
||||
|
@ -1040,6 +1042,7 @@ impl PipShowSettings {
|
|||
python,
|
||||
system,
|
||||
no_system,
|
||||
compat_args: _,
|
||||
} = args;
|
||||
|
||||
Self {
|
||||
|
@ -1080,6 +1083,7 @@ impl PipTreeSettings {
|
|||
python,
|
||||
system,
|
||||
no_system,
|
||||
compat_args: _,
|
||||
} = args;
|
||||
|
||||
Self {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue