Skip to content

Commit

Permalink
Add support for Rangy input in parse_range function and implement cor…
Browse files Browse the repository at this point in the history
…responding test
  • Loading branch information
arthur-debert committed Dec 6, 2024
1 parent 04b5093 commit 4daf83f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
4 changes: 4 additions & 0 deletions rangy/parse.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,10 @@ def parse_range(range_input):
Raises:
ParseRangeError: If the input is invalid or cannot be parsed.
"""
from rangy import Rangy
# short circuit if it's already a rangy
if isinstance(range_input, Rangy):
return range_input.values

start, end = _normalize_to_sequence(range_input)

Expand Down
7 changes: 7 additions & 0 deletions tests/parser/test_from_rangy.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import pytest

from rangy import parse_range, Rangy

def test_from_rangy():
res = parse_range(Rangy((1, 3)))
assert res == (1, 3)

0 comments on commit 4daf83f

Please sign in to comment.