Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions crates/uv-pep508/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1457,6 +1457,13 @@ mod tests {
Requirement::<Url>::from_str(r#"numpy; sys_platform == "win32" or (os_name == "linux" and implementation_name == 'cpython')"#).unwrap();
}

#[test]
fn reversed_compatible_release_string_marker() {
let requirement = Requirement::<Url>::from_str(r#"foo; "3" ~= sys_platform"#).unwrap();

assert_eq!(requirement.to_string(), "foo");
}

#[test]
fn error_marker_incomplete1() {
assert_snapshot!(
Expand Down
23 changes: 17 additions & 6 deletions crates/uv-pep508/src/marker/parse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -282,12 +282,23 @@ pub(crate) fn parse_marker_key_op_value<T: Pep508Url>(
parse_inverted_version_expr(&l_string, operator, key, reporter)
}
// '...' == <env key>
MarkerValue::MarkerEnvString(key) => Some(MarkerExpression::String {
key,
// Invert the operator to normalize the expression order.
operator: operator.invert(),
value: l_string,
}),
MarkerValue::MarkerEnvString(key) => {
if operator == MarkerOperator::TildeEqual {
reporter.report(
MarkerWarningKind::LexicographicComparison,
"Can't compare strings with `~=`, will be ignored".to_string(),
);

return Ok(None);
}

Some(MarkerExpression::String {
key,
// Invert the operator to normalize the expression order.
operator: operator.invert(),
value: l_string,
})
}
// `"test" in extras` or `"dev" in dependency_groups`
MarkerValue::MarkerEnvList(key) => {
let operator =
Expand Down
Loading