mirror of
https://github.com/astral-sh/uv.git
synced 2025-11-02 21:02:37 +00:00
pep508: add PartialOrd and Ord implementations to MarkerTree
Since we're adding a `Option<MarkerTree>` to `PubGrubPackage`, and since we just make `PubGrubPackage` implement `Ord`, it follows that we want `MarkerTree` to also implement `Ord`.
This commit is contained in:
parent
1ed3555bf0
commit
d0435ef20a
3 changed files with 30 additions and 9 deletions
|
|
@ -15,7 +15,17 @@ use serde::{de, Deserialize, Deserializer, Serialize, Serializer};
|
||||||
|
|
||||||
/// One of `~=` `==` `!=` `<=` `>=` `<` `>` `===`
|
/// One of `~=` `==` `!=` `<=` `>=` `<` `>` `===`
|
||||||
#[derive(
|
#[derive(
|
||||||
Eq, PartialEq, Debug, Hash, Clone, Copy, rkyv::Archive, rkyv::Deserialize, rkyv::Serialize,
|
Eq,
|
||||||
|
Ord,
|
||||||
|
PartialEq,
|
||||||
|
PartialOrd,
|
||||||
|
Debug,
|
||||||
|
Hash,
|
||||||
|
Clone,
|
||||||
|
Copy,
|
||||||
|
rkyv::Archive,
|
||||||
|
rkyv::Deserialize,
|
||||||
|
rkyv::Serialize,
|
||||||
)]
|
)]
|
||||||
#[archive(check_bytes)]
|
#[archive(check_bytes)]
|
||||||
#[archive_attr(derive(Debug, Eq, PartialEq, PartialOrd, Ord))]
|
#[archive_attr(derive(Debug, Eq, PartialEq, PartialOrd, Ord))]
|
||||||
|
|
|
||||||
|
|
@ -250,7 +250,18 @@ impl std::error::Error for VersionSpecifiersParseError {}
|
||||||
/// let version_specifier = VersionSpecifier::from_str("== 1.*").unwrap();
|
/// let version_specifier = VersionSpecifier::from_str("== 1.*").unwrap();
|
||||||
/// assert!(version_specifier.contains(&version));
|
/// assert!(version_specifier.contains(&version));
|
||||||
/// ```
|
/// ```
|
||||||
#[derive(Eq, PartialEq, Debug, Clone, Hash, rkyv::Archive, rkyv::Deserialize, rkyv::Serialize)]
|
#[derive(
|
||||||
|
Eq,
|
||||||
|
Ord,
|
||||||
|
PartialEq,
|
||||||
|
PartialOrd,
|
||||||
|
Debug,
|
||||||
|
Clone,
|
||||||
|
Hash,
|
||||||
|
rkyv::Archive,
|
||||||
|
rkyv::Deserialize,
|
||||||
|
rkyv::Serialize,
|
||||||
|
)]
|
||||||
#[archive(check_bytes)]
|
#[archive(check_bytes)]
|
||||||
#[archive_attr(derive(Debug))]
|
#[archive_attr(derive(Debug))]
|
||||||
#[cfg_attr(feature = "pyo3", pyclass(get_all))]
|
#[cfg_attr(feature = "pyo3", pyclass(get_all))]
|
||||||
|
|
|
||||||
|
|
@ -63,7 +63,7 @@ impl MarkerWarningKind {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Those environment markers with a PEP 440 version as value such as `python_version`
|
/// Those environment markers with a PEP 440 version as value such as `python_version`
|
||||||
#[derive(Clone, Debug, Eq, Hash, PartialEq)]
|
#[derive(Clone, Debug, Eq, Hash, PartialEq, PartialOrd, Ord)]
|
||||||
#[allow(clippy::enum_variant_names)]
|
#[allow(clippy::enum_variant_names)]
|
||||||
pub enum MarkerValueVersion {
|
pub enum MarkerValueVersion {
|
||||||
/// `implementation_version`
|
/// `implementation_version`
|
||||||
|
|
@ -85,7 +85,7 @@ impl Display for MarkerValueVersion {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Those environment markers with an arbitrary string as value such as `sys_platform`
|
/// Those environment markers with an arbitrary string as value such as `sys_platform`
|
||||||
#[derive(Clone, Debug, Eq, Hash, PartialEq)]
|
#[derive(Clone, Debug, Eq, Hash, PartialEq, PartialOrd, Ord)]
|
||||||
pub enum MarkerValueString {
|
pub enum MarkerValueString {
|
||||||
/// `implementation_name`
|
/// `implementation_name`
|
||||||
ImplementationName,
|
ImplementationName,
|
||||||
|
|
@ -142,7 +142,7 @@ impl Display for MarkerValueString {
|
||||||
/// One of the predefined environment values
|
/// One of the predefined environment values
|
||||||
///
|
///
|
||||||
/// <https://packaging.python.org/en/latest/specifications/dependency-specifiers/#environment-markers>
|
/// <https://packaging.python.org/en/latest/specifications/dependency-specifiers/#environment-markers>
|
||||||
#[derive(Clone, Debug, Eq, Hash, PartialEq)]
|
#[derive(Clone, Debug, Eq, Hash, PartialEq, PartialOrd, Ord)]
|
||||||
pub enum MarkerValue {
|
pub enum MarkerValue {
|
||||||
/// Those environment markers with a PEP 440 version as value such as `python_version`
|
/// Those environment markers with a PEP 440 version as value such as `python_version`
|
||||||
MarkerEnvVersion(MarkerValueVersion),
|
MarkerEnvVersion(MarkerValueVersion),
|
||||||
|
|
@ -214,7 +214,7 @@ impl Display for MarkerValue {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// How to compare key and value, such as by `==`, `>` or `not in`
|
/// How to compare key and value, such as by `==`, `>` or `not in`
|
||||||
#[derive(Copy, Clone, Debug, Eq, Hash, PartialEq)]
|
#[derive(Copy, Clone, Debug, Eq, Hash, PartialEq, PartialOrd, Ord)]
|
||||||
pub enum MarkerOperator {
|
pub enum MarkerOperator {
|
||||||
/// `==`
|
/// `==`
|
||||||
Equal,
|
Equal,
|
||||||
|
|
@ -900,7 +900,7 @@ impl<'a> TryFrom<MarkerEnvironmentBuilder<'a>> for MarkerEnvironment {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Represents one clause such as `python_version > "3.8"`.
|
/// Represents one clause such as `python_version > "3.8"`.
|
||||||
#[derive(Clone, Debug, Eq, Hash, PartialEq)]
|
#[derive(Clone, Debug, Eq, Hash, PartialEq, PartialOrd, Ord)]
|
||||||
#[allow(missing_docs)]
|
#[allow(missing_docs)]
|
||||||
pub enum MarkerExpression {
|
pub enum MarkerExpression {
|
||||||
/// A version expression, e.g. `<version key> <version op> <quoted PEP 440 version>`.
|
/// A version expression, e.g. `<version key> <version op> <quoted PEP 440 version>`.
|
||||||
|
|
@ -943,7 +943,7 @@ pub enum MarkerExpression {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The operator for an extra expression, either '==' or '!='.
|
/// The operator for an extra expression, either '==' or '!='.
|
||||||
#[derive(Clone, Debug, Eq, Hash, PartialEq)]
|
#[derive(Clone, Debug, Eq, Hash, PartialEq, PartialOrd, Ord)]
|
||||||
pub enum ExtraOperator {
|
pub enum ExtraOperator {
|
||||||
/// `==`
|
/// `==`
|
||||||
Equal,
|
Equal,
|
||||||
|
|
@ -1529,7 +1529,7 @@ impl Display for MarkerExpression {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Represents one of the nested marker expressions with and/or/parentheses
|
/// Represents one of the nested marker expressions with and/or/parentheses
|
||||||
#[derive(Clone, Debug, Eq, Hash, PartialEq)]
|
#[derive(Clone, Debug, Eq, Hash, PartialEq, PartialOrd, Ord)]
|
||||||
pub enum MarkerTree {
|
pub enum MarkerTree {
|
||||||
/// A simple expression such as `python_version > "3.8"`
|
/// A simple expression such as `python_version > "3.8"`
|
||||||
Expression(MarkerExpression),
|
Expression(MarkerExpression),
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue