From 135efc57e9e4cb266c8dc697ccb7234afad3ffcd Mon Sep 17 00:00:00 2001 From: David Hotham Date: Sun, 6 Feb 2022 18:46:37 +0000 Subject: [PATCH 1/2] Marker name is a string, not a lexer token --- src/poetry/core/version/markers.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/poetry/core/version/markers.py b/src/poetry/core/version/markers.py index 7b2e98627..bb894028e 100644 --- a/src/poetry/core/version/markers.py +++ b/src/poetry/core/version/markers.py @@ -737,7 +737,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()) From f2382c916cadbbfbd4e4a913b2d15a815f6473ac Mon Sep 17 00:00:00 2001 From: David Hotham Date: Fri, 11 Feb 2022 20:49:48 +0000 Subject: [PATCH 2/2] add unit test --- tests/packages/test_dependency.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tests/packages/test_dependency.py b/tests/packages/test_dependency.py index cbcc7d484..6038417f9 100644 --- a/tests/packages/test_dependency.py +++ b/tests/packages/test_dependency.py @@ -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