Don't mix falsy value with no value

This commit is contained in:
əlemi 2022-05-23 02:14:17 +02:00
parent 4c6d906d3a
commit d2a13360a8
No known key found for this signature in database
GPG key ID: BBCBFE5D7244634E

View file

@ -56,7 +56,11 @@ class Treepuncher(
authenticator : AuthInterface authenticator : AuthInterface
def opt(k:str, required=False, default=None, t:type=str) -> Any: def opt(k:str, required=False, default=None, t:type=str) -> Any:
v = kwargs.get(k) or self.cfg.get(k) or default v = kwargs.get(k)
if v is None:
v = self.cfg.get(k)
if v is None:
v = default
if not v and required: if not v and required:
raise MissingParameterError(f"Missing configuration parameter '{k}'") raise MissingParameterError(f"Missing configuration parameter '{k}'")
if t is bool and isinstance(v, str) and v.lower().strip() == 'false': # hardcoded special case if t is bool and isinstance(v, str) and v.lower().strip() == 'false': # hardcoded special case