Skip to content

Commit

Permalink
Change suffix_union to raise ValueError
Browse files Browse the repository at this point in the history
  • Loading branch information
maresb authored Oct 16, 2023
1 parent f567e46 commit e1ead32
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions conda_lock/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def suffix_union(collections: Iterable[Sequence]) -> List:
>>> suffix_union([[1], [2, 1], [4, 1]])
Traceback (most recent call last)
...
RuntimeError: [4, 1] is not an ordered subset of [2, 1]
ValueError: [4, 1] is not an ordered subset of [2, 1]
"""
return list(reversed(prefix_union([list(reversed(s)) for s in collections])))
Expand All @@ -105,15 +105,15 @@ def prefix_union(collections: Iterable[Sequence]) -> List:
>>> prefix_union([[1], [1, 2], [1, 4]])
Traceback (most recent call last)
...
RuntimeError: [1, 4] is not an ordered subset of [1, 2]
ValueError: [1, 4] is not an ordered subset of [1, 2]
"""
result: List = []
for seq in collections:
for i, item in enumerate(seq):
if i >= len(result):
result.append(item)
elif result[i] != item:
raise RuntimeError(f"{seq} is not an ordered subset of {result}")
raise ValueError(f"{seq} is not an ordered subset of {result}")
return result


Expand Down

0 comments on commit e1ead32

Please sign in to comment.