Skip to content

Commit

Permalink
Add SPECIAL_CHARS to exports and update _parse logic to handle specia…
Browse files Browse the repository at this point in the history
…l characters
  • Loading branch information
arthur-debert committed Dec 4, 2024
1 parent 84a96d4 commit a11460d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions rangy/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from .const import ANY, AT_LEAST_ONE, EXACT, RANGE, COUNT_TYPES, INFINITY, ANY_CHAR, ONE_PLUS_CHAR
from .const import ANY, AT_LEAST_ONE, EXACT, RANGE, COUNT_TYPES, INFINITY, ANY_CHAR, ONE_PLUS_CHAR, SPECIAL_CHARS
from .converters import Converter
from .registry import ConverterRegistry
from .builtins import register_builtins
Expand All @@ -7,4 +7,4 @@
from .parse import parse_range, _normalize_to_sequence, _convert_string_part

register_builtins()
__all__ = ["ANY", "AT_LEAST_ONE", "EXACT", "RANGE", "COUNT_TYPES", "INFINITY", "ANY_CHAR", "ONE_PLUS_CHAR", "Converter", "ConverterRegistry", "Rangy", "_parse", "distribute", "parse_range", "_normalize_to_sequence", "_convert_string_part"]
__all__ = ["ANY", "AT_LEAST_ONE", "EXACT", "RANGE", "COUNT_TYPES", "INFINITY", "ANY_CHAR", "ONE_PLUS_CHAR", "SPECIAL_CHARS", "Converter", "ConverterRegistry", "Rangy", "_parse", "distribute", "parse_range", "_normalize_to_sequence", "_convert_string_part"]
6 changes: 3 additions & 3 deletions rangy/rangy.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from typing import Tuple, Union

from rangy import (ANY, ANY_CHAR, AT_LEAST_ONE, EXACT, INFINITY, ONE_PLUS_CHAR,
RANGE)
RANGE, SPECIAL_CHARS)
from rangy.exceptions import ParseRangeError

RangyType = Union[int, str]
Expand Down Expand Up @@ -57,8 +57,8 @@ def _parse(self, rangy) -> Tuple[Union[int, float], Union[int, float]]:
else:
raise ParseRangeError(f"Invalid rangy specification: {rangy}")

min_val = int(min_val) if min_val not in ("*", "+") else min_val
max_val = int(max_val) if max_val not in ("*", "+") else max_val
min_val = int(min_val) if min_val not in (SPECIAL_CHARS) else min_val
max_val = int(max_val) if max_val not in (SPECIAL_CHARS) else max_val

if min_val == '*':
min_val = 0
Expand Down

0 comments on commit a11460d

Please sign in to comment.