From 1ac68a983648d865beab902ea19a661bb7c3cbbf Mon Sep 17 00:00:00 2001 From: jesopo Date: Mon, 9 Mar 2020 08:23:07 +0000 Subject: allow IntRangeSetting max to be optional --- src/utils/settings.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/utils/settings.py b/src/utils/settings.py index 97fe885b..53ee0ebd 100644 --- a/src/utils/settings.py +++ b/src/utils/settings.py @@ -49,15 +49,17 @@ class IntSetting(Setting): class IntRangeSetting(IntSetting): example: typing.Optional[str] = None - def __init__(self, n_min: int, n_max: int, name: str, help: str=None, - example: str=None): + def __init__(self, n_min: int, n_max: typing.Optional[int], name: str, + help: str=None, example: str=None): self._n_min = n_min self._n_max = n_max Setting.__init__(self, name, help, example) def parse(self, value: str) -> typing.Any: out = IntSetting.parse(self, value) - if not out == None and self._n_min <= out <= self._n_max: + if (not out == None and + self._n_min <= out and + (self._n_max == None or out <= self._n_max)): return out return None -- cgit v1.3.1-10-gc9f91