Skip to content

Commit

Permalink
Evaluate arbitrary markers to false (astral-sh#3681)
Browse files Browse the repository at this point in the history
## Summary

See: astral-sh#3679 (comment).

Closes: astral-sh#3675 (although I think we
have another improvement to make there -- will file separately).
  • Loading branch information
charliermarsh authored May 21, 2024
1 parent 776a7e4 commit 0362918
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
2 changes: 1 addition & 1 deletion crates/pep508-rs/src/marker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1345,7 +1345,7 @@ impl MarkerExpression {
operator: ExtraOperator::NotEqual,
name,
} => !extras.contains(name),
MarkerExpression::Arbitrary { .. } => true,
MarkerExpression::Arbitrary { .. } => false,
}
}

Expand Down
17 changes: 10 additions & 7 deletions crates/uv-resolver/src/marker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,18 @@ pub(crate) fn is_disjoint(first: &MarkerTree, second: &MarkerTree) -> bool {
}
};

match expr1 {
MarkerExpression::Version { .. } | MarkerExpression::VersionInverted { .. } => {
match (expr1, expr2) {
// `Arbitrary` expressions always evaluate to `false`, and are thus always disjoint.
(MarkerExpression::Arbitrary { .. }, _) | (_, MarkerExpression::Arbitrary { .. }) => true,
(MarkerExpression::Version { .. } | MarkerExpression::VersionInverted { .. }, expr2) => {
version_is_disjoint(expr1, expr2)
}
MarkerExpression::String { .. } | MarkerExpression::StringInverted { .. } => {
(MarkerExpression::String { .. } | MarkerExpression::StringInverted { .. }, expr2) => {
string_is_disjoint(expr1, expr2)
}
MarkerExpression::Extra { operator, name } => extra_is_disjoint(operator, name, expr2),
MarkerExpression::Arbitrary { .. } => false,
(MarkerExpression::Extra { operator, name }, expr2) => {
extra_is_disjoint(operator, name, expr2)
}
}
}

Expand Down Expand Up @@ -240,8 +243,8 @@ mod tests {
}

#[test]
fn invalid() {
assert!(!is_disjoint(
fn arbitrary() {
assert!(is_disjoint(
"python_version == 'Linux'",
"python_version == '3.7.1'"
));
Expand Down

0 comments on commit 0362918

Please sign in to comment.