From d2a13360a82ad48ad180d98b940369a337773afa Mon Sep 17 00:00:00 2001 From: alemidev Date: Mon, 23 May 2022 02:14:17 +0200 Subject: [PATCH] Don't mix falsy value with no value --- src/treepuncher/treepuncher.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/treepuncher/treepuncher.py b/src/treepuncher/treepuncher.py index a479c03..318e749 100644 --- a/src/treepuncher/treepuncher.py +++ b/src/treepuncher/treepuncher.py @@ -56,7 +56,11 @@ class Treepuncher( authenticator : AuthInterface 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: raise MissingParameterError(f"Missing configuration parameter '{k}'") if t is bool and isinstance(v, str) and v.lower().strip() == 'false': # hardcoded special case