mirror of
https://github.com/astral-sh/uv.git
synced 2025-11-17 18:57:30 +00:00
Ban pre-release versions in uv python upgrade requests (#16160)
This commit is contained in:
parent
37b3557dab
commit
3a507e69b2
3 changed files with 60 additions and 3 deletions
|
|
@ -1945,6 +1945,24 @@ impl PythonRequest {
|
|||
}
|
||||
}
|
||||
|
||||
/// Check if this request includes a specific prerelease version.
|
||||
pub fn includes_prerelease(&self) -> bool {
|
||||
match self {
|
||||
Self::Default => false,
|
||||
Self::Any => false,
|
||||
Self::Version(version_request) => version_request.prerelease().is_some(),
|
||||
Self::Directory(..) => false,
|
||||
Self::File(..) => false,
|
||||
Self::ExecutableName(..) => false,
|
||||
Self::Implementation(..) => false,
|
||||
Self::ImplementationVersion(_, version) => version.prerelease().is_some(),
|
||||
Self::Key(request) => request
|
||||
.version
|
||||
.as_ref()
|
||||
.is_some_and(|request| request.prerelease().is_some()),
|
||||
}
|
||||
}
|
||||
|
||||
/// Check if a given interpreter satisfies the interpreter request.
|
||||
pub fn satisfied(&self, interpreter: &Interpreter, cache: &Cache) -> bool {
|
||||
/// Returns `true` if the two paths refer to the same interpreter executable.
|
||||
|
|
@ -2565,6 +2583,17 @@ impl VersionRequest {
|
|||
}
|
||||
}
|
||||
|
||||
/// Return the pre-release segment of the request, if any.
|
||||
pub(crate) fn prerelease(&self) -> Option<&Prerelease> {
|
||||
match self {
|
||||
Self::Any | Self::Default | Self::Range(_, _) => None,
|
||||
Self::Major(_, _) => None,
|
||||
Self::MajorMinor(_, _, _) => None,
|
||||
Self::MajorMinorPatch(_, _, _, _) => None,
|
||||
Self::MajorMinorPrerelease(_, _, prerelease, _) => Some(prerelease),
|
||||
}
|
||||
}
|
||||
|
||||
/// Check if the request is for a version supported by uv.
|
||||
///
|
||||
/// If not, an `Err` is returned with an explanatory message.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue