mirror of
				https://github.com/astral-sh/uv.git
				synced 2025-10-31 12:06:13 +00:00 
			
		
		
		
	Filter out markers based on Python requirement (#4912)
## Summary In marker normalization, we now remove any markers that are redundant with the `requires-python` specifier (i.e., always true for the given Python requirement). For example, given `iniconfig ; python_version >= '3.7'`, we can remove the `python_version >= '3.7'` marker when resolving with `--python-version 3.8`. Closes #4852.
This commit is contained in:
		
							parent
							
								
									ef120dcc54
								
							
						
					
					
						commit
						72dd34b225
					
				
					 8 changed files with 146 additions and 48 deletions
				
			
		|  | @ -155,6 +155,11 @@ impl RequiresPython { | |||
|         self.bound.as_ref() == Bound::Unbounded | ||||
|     } | ||||
| 
 | ||||
|     /// Returns the [`RequiresPythonBound`] for the `Requires-Python` specifier.
 | ||||
|     pub fn bound(&self) -> &RequiresPythonBound { | ||||
|         &self.bound | ||||
|     } | ||||
| 
 | ||||
|     /// Returns this `Requires-Python` specifier as an equivalent marker
 | ||||
|     /// expression utilizing the `python_version` marker field.
 | ||||
|     ///
 | ||||
|  | @ -254,6 +259,16 @@ impl RequiresPythonBound { | |||
|     } | ||||
| } | ||||
| 
 | ||||
| impl From<RequiresPythonBound> for Range<Version> { | ||||
|     fn from(value: RequiresPythonBound) -> Self { | ||||
|         match value.0 { | ||||
|             Bound::Included(version) => Range::higher_than(version), | ||||
|             Bound::Excluded(version) => Range::strictly_higher_than(version), | ||||
|             Bound::Unbounded => Range::full(), | ||||
|         } | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| impl Deref for RequiresPythonBound { | ||||
|     type Target = Bound<Version>; | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Charlie Marsh
						Charlie Marsh