diff --git a/setup.py b/setup.py index 9356dd1..088ecd4 100644 --- a/setup.py +++ b/setup.py @@ -7,7 +7,7 @@ setup( name='smart_range', - version='1.1.0', + version='1.1.1', packages=['smart_range'], url='https://github.com/PythonCoderAS/SmartRange', license='MIT', diff --git a/smart_range/smart_range.py b/smart_range/smart_range.py index 8390776..1fca152 100644 --- a/smart_range/smart_range.py +++ b/smart_range/smart_range.py @@ -6,7 +6,7 @@ class SmartRange: """The class that represents a range of values. Input consists of a string containing the range. - A range string is a comma-separated list of range items. There are 4 types of range items supported by the class: + A range string is a comma-separated list of range items. There are 5 types of range items supported by the class: #. Classic range with a defined start and finish. Example: ``1-5`` @@ -34,6 +34,10 @@ class SmartRange: `` - `` * Example where the range string is ``1-5,+8`` -> ``1-5,6-13`` + + #. A singular dash, indicating a range with an undefined start and an undefined finish. This requires the + ``min_val`` and the ``max_val`` parameter to be supplied to the :py:meth:`~SmartRange.__init__` method. + Additionally, this item can only show up once at the end of a range string. Example: ``-`` """ ranges: List[range] @@ -114,9 +118,9 @@ def _parse_range(self, range_str: str, min_val: Optional[int] = None, max_val: O end = start + int(part[1:]) - 1 # If we say +25, we want 25 numbers, not to end at the 25th index (26 numbers). if start is None: - raise NoMinimumValueError(part) + raise NoMinimumValueError(end) if end is None: - raise NoMaximumValueError(part) + raise NoMaximumValueError(start) if end < start: raise NegativeRangeError(start, end) if locked_max and max(start, end) > locked_max: @@ -126,7 +130,7 @@ def _parse_range(self, range_str: str, min_val: Optional[int] = None, max_val: O return ranges def __iter__(self) -> Generator[int, None, None]: - """Returns a generator containing all of the numbers in the smart range. + """Returns a generator containing all the numbers in the smart range. .. note:: In order to iterate over the list of range objects, use the :py:attr:`ranges` attribute, such as: