allow IntRangeSetting max to be optional
This commit is contained in:
parent
0cdd234c5c
commit
1ac68a9836
1 changed files with 5 additions and 3 deletions
|
@ -49,15 +49,17 @@ class IntSetting(Setting):
|
||||||
|
|
||||||
class IntRangeSetting(IntSetting):
|
class IntRangeSetting(IntSetting):
|
||||||
example: typing.Optional[str] = None
|
example: typing.Optional[str] = None
|
||||||
def __init__(self, n_min: int, n_max: int, name: str, help: str=None,
|
def __init__(self, n_min: int, n_max: typing.Optional[int], name: str,
|
||||||
example: str=None):
|
help: str=None, example: str=None):
|
||||||
self._n_min = n_min
|
self._n_min = n_min
|
||||||
self._n_max = n_max
|
self._n_max = n_max
|
||||||
Setting.__init__(self, name, help, example)
|
Setting.__init__(self, name, help, example)
|
||||||
|
|
||||||
def parse(self, value: str) -> typing.Any:
|
def parse(self, value: str) -> typing.Any:
|
||||||
out = IntSetting.parse(self, value)
|
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 out
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue