From 5cdac563e562dc7d2f3ff1cb6a523c0e887e235d Mon Sep 17 00:00:00 2001 From: Andrew Gallant Date: Fri, 22 Nov 2024 08:40:22 -0500 Subject: [PATCH] uv-resolver: remove `ResolverEnvironment::try_markers` This was almost not used any more with the refactor toward 'UniversalMarker', so this just removes the final uses. --- .../uv-resolver/src/resolver/environment.rs | 38 +++++-------------- 1 file changed, 9 insertions(+), 29 deletions(-) diff --git a/crates/uv-resolver/src/resolver/environment.rs b/crates/uv-resolver/src/resolver/environment.rs index 866fbd456..f1fef15c4 100644 --- a/crates/uv-resolver/src/resolver/environment.rs +++ b/crates/uv-resolver/src/resolver/environment.rs @@ -172,8 +172,14 @@ impl ResolverEnvironment { /// Returns the bounding Python versions that can satisfy this /// resolver environment's marker, if it's constrained. pub(crate) fn requires_python(&self) -> Option { - let marker = self.try_markers().unwrap_or(&MarkerTree::TRUE); - crate::marker::requires_python(marker) + let Kind::Universal { + markers: ref pep508_marker, + .. + } = self.kind + else { + return None; + }; + crate::marker::requires_python(pep508_marker) } /// Narrow this environment given the forking markers. @@ -292,7 +298,7 @@ impl ResolverEnvironment { &self, python_requirement: &PythonRequirement, ) -> Option { - python_requirement.narrow(&self.requires_python_range()?) + python_requirement.narrow(&self.requires_python()?) } /// Returns a message formatted for end users representing a fork in the @@ -317,23 +323,6 @@ impl ResolverEnvironment { } } - /// Returns the marker expression corresponding to the fork that is - /// represented by this resolver environment. - /// - /// This returns `None` when this does not correspond to a fork. - pub(crate) fn try_markers(&self) -> Option<&MarkerTree> { - match self.kind { - Kind::Specific { .. } => None, - Kind::Universal { ref markers, .. } => { - if markers.is_true() { - None - } else { - Some(markers) - } - } - } - } - /// Creates a universal marker expression corresponding to the fork that is /// represented by this resolver environment. A universal marker includes /// not just the standard PEP 508 marker, but also a marker based on @@ -349,15 +338,6 @@ impl ResolverEnvironment { } } } - - /// Returns a requires-python version range derived from the marker - /// expression describing this resolver environment. - /// - /// When this isn't a fork, then there is nothing to constrain and thus - /// `None` is returned. - fn requires_python_range(&self) -> Option { - crate::marker::requires_python(self.try_markers()?) - } } /// A user visible representation of a resolver environment.