Skip to content

Commit

Permalink
Normalize marker expression order (#5422)
Browse files Browse the repository at this point in the history
## Summary

Normalize the order of marker expressions on construction. This removes
the distinction between expressions like `os_name == 'Linux'` vs.
`'Linux' == os_name` throughout the codebase. One caveat here is that
the `in` operator does not have a direct inverse, so we introduce
`MarkerOperator::Contains` to handle that case.

I wanted to land this smaller change before some more intrusive changes
as it simplifies the existing code quite a bit.
  • Loading branch information
ibraheemdev committed Jul 24, 2024
1 parent 35b6726 commit 39be71f
Show file tree
Hide file tree
Showing 4 changed files with 109 additions and 264 deletions.
5 changes: 4 additions & 1 deletion crates/pep508-rs/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1804,8 +1804,11 @@ mod tests {

#[test]
fn no_space_after_operator() {
let requirement = Requirement::<Url>::from_str("pytest;python_version<='4.0'").unwrap();
assert_eq!(requirement.to_string(), "pytest ; python_version <= '4.0'");

let requirement = Requirement::<Url>::from_str("pytest;'4.0'>=python_version").unwrap();
assert_eq!(requirement.to_string(), "pytest ; '4.0' >= python_version");
assert_eq!(requirement.to_string(), "pytest ; python_version <= '4.0'");
}

#[test]
Expand Down
Loading

0 comments on commit 39be71f

Please sign in to comment.