support '0' as an IntSetting value

This commit is contained in:
jesopo 2019-09-15 22:22:30 +01:00
parent 621fb0b396
commit f9d13dc373

View file

@ -298,9 +298,12 @@ class BoolSetting(Setting):
class IntSetting(Setting):
example = "10"
def parse(self, value: str) -> typing.Any:
stripped = value.lstrip("0")
if stripped.isdigit():
return int(stripped)
if value == "0":
return 0
else:
stripped = value.lstrip("0")
if stripped.isdigit():
return int(stripped)
return None
class IntRangeSetting(IntSetting):