Skip to content

Commit

Permalink
allow prerelease versions in marker evaluation
Browse files Browse the repository at this point in the history
Fixes  #522
  • Loading branch information
graingert committed Mar 16, 2022
1 parent 35c50dc commit a81e314
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packaging/markers.py
Expand Up @@ -192,7 +192,7 @@ def _eval_op(lhs: str, op: Op, rhs: str) -> bool:
except InvalidSpecifier:
pass
else:
return spec.contains(lhs)
return spec.contains(lhs, prereleases=True)

oper: Optional[Operator] = _operators.get(op.serialize())
if oper is None:
Expand Down
5 changes: 5 additions & 0 deletions tests/test_markers.py
Expand Up @@ -86,6 +86,11 @@ def test_fails_when_undefined(self):
with pytest.raises(UndefinedComparison):
Marker("'2.7.0' ~= os_name").evaluate()

def test_allows_prerelease(self):
assert Marker('python_full_version > "3.6.2"').evaluate(
{"python_full_version": "3.11.0a5"}
)


FakeVersionInfo = collections.namedtuple(
"FakeVersionInfo", ["major", "minor", "micro", "releaselevel", "serial"]
Expand Down

0 comments on commit a81e314

Please sign in to comment.