aboutsummaryrefslogtreecommitdiff
path: root/src/utils
diff options
context:
space:
mode:
authorGravatar jesopo2020-03-09 08:23:07 +0000
committerGravatar jesopo2020-03-09 08:23:07 +0000
commit1ac68a983648d865beab902ea19a661bb7c3cbbf (patch)
treea04258787797f4aa454b90f67d41c60635decaf5 /src/utils
parentdon't skip already "short" urls in yourls.py - can't predict output length (diff)
signature
allow IntRangeSetting max to be optional
Diffstat (limited to 'src/utils')
-rw-r--r--src/utils/settings.py8
1 files changed, 5 insertions, 3 deletions
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