Skip to content

Commit

Permalink
Marker name is a string, not a lexer token (python-poetry#286)
Browse files Browse the repository at this point in the history
* Marker name is a string, not a lexer token

* add unit test
  • Loading branch information
dimbleby authored and bostonrwalker committed Aug 29, 2022
1 parent 3483c2d commit 71ddd55
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/poetry/core/version/markers.py
Original file line number Diff line number Diff line change
Expand Up @@ -742,7 +742,9 @@ def _compact_markers(tree_elements: "Tree", tree_prefix: str = "") -> MarkerType
)

value = value[1:-1]
groups[-1] = MultiMarker.of(groups[-1], SingleMarker(name, f"{op}{value}"))
groups[-1] = MultiMarker.of(
groups[-1], SingleMarker(str(name), f"{op}{value}")
)
elif token.data == f"{tree_prefix}BOOL_OP" and token.children[0] == "or":
groups.append(MultiMarker())

Expand Down
7 changes: 7 additions & 0 deletions tests/packages/test_dependency.py
Original file line number Diff line number Diff line change
Expand Up @@ -298,3 +298,10 @@ def test_marker_properly_sets_python_constraint():
dependency.marker = 'python_version >= "3.6" and python_version < "4.0"'

assert str(dependency.python_constraint) == ">=3.6,<4.0"


def test_dependency_markers_are_the_same_as_markers():
dependency = Dependency.create_from_pep_508('foo ; extra=="bar"')
marker = parse_marker('extra=="bar"')

assert dependency.marker == marker

0 comments on commit 71ddd55

Please sign in to comment.