Skip to content

Commit

Permalink
Fix extracting extras from markers with many extras (#2792)
Browse files Browse the repository at this point in the history
Co-authored-by: Bernát Gábor <gaborjbernat@gmail.com>
  • Loading branch information
q0w and gaborbernat committed Dec 31, 2022
1 parent a3d3ec0 commit 196b20d
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
1 change: 1 addition & 0 deletions docs/changelog/2791.bugfix.rst
@@ -0,0 +1 @@
Fix extracting extras from markers with many extras - by :user:`q0w`.
3 changes: 1 addition & 2 deletions src/tox/tox_env/python/virtual_env/package/util.py
Expand Up @@ -45,10 +45,9 @@ def extract_extra_markers(deps: list[Requirement]) -> list[tuple[Requirement, se
extra_markers.add(marker_value.value)
del markers[_at]
_at -= 1
if _at > 0 and (isinstance(markers[_at], str) and markers[_at] in ("and", "or")):
if _at >= 0 and (isinstance(markers[_at], str) and markers[_at] in ("and", "or")):
del markers[_at]
if len(markers) == 0:
req.marker = None
break
result.append((req, extra_markers or {None}))
return result
Expand Up @@ -63,3 +63,9 @@ def test_loads_deps_recursive_extras() -> None:
]
result = dependencies_with_extras(requires, {"dev"}, "name")
assert [str(i) for i in result] == ["no-extra", "dep1[magic]", "dep1", "dep2[a,b]"]


def test_load_dependency_requirement_or_extras() -> None:
requires = [Requirement('filelock<4.0.0,>=3.9.0; extra == "extras1" or extra == "extras2"')]
result = dependencies_with_extras(requires, {"extras1"}, "")
assert [str(r) for r in result] == ["filelock<4.0.0,>=3.9.0"]

0 comments on commit 196b20d

Please sign in to comment.