From 75d290067d4cfd29784b8c3fa080f0953072ef32 Mon Sep 17 00:00:00 2001 From: Austin Appleby Date: Fri, 15 Mar 2024 21:10:40 -0700 Subject: [PATCH] Fix tiny bug with Rule missing field lookup when super.field is falsy --- hancho.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/hancho.py b/hancho.py index b2a162d..cdf8bad 100755 --- a/hancho.py +++ b/hancho.py @@ -175,7 +175,7 @@ async def flatten_variant(rule, variant, depth=0): result.extend(await flatten_variant(rule, element, depth + 1)) return result - return [await stringize_variant(rule, variant, depth+1)] + return [await stringize_variant(rule, variant, depth + 1)] async def stringize_variant(rule, variant, depth=0): @@ -250,7 +250,7 @@ def load(mod_path): test_path = abspath(Path(app.mod_stack[-1].__file__).parent / mod_path) if test_path.exists(): - #print(f"load_module({test_path})") + # print(f"load_module({test_path})") result = app.load_module(test_path) return result raise FileNotFoundError(f"Could not load module {mod_path}") @@ -324,7 +324,7 @@ def __missing__(self, key): """Rules delegate to config[key] if a key is missing.""" result = super().__missing__(key) - return result if result else config[key] + return result if result is not None else config[key] def __call__(self, files_in, files_out=None, **kwargs): task = Task(base=self, **kwargs) @@ -339,7 +339,7 @@ def __call__(self, files_in, files_out=None, **kwargs): # A task that's created during task execution instead of module loading will have no mod # stack entry to pull load_dir from, so it runs from '.' (root_dir) instead. - if not "load_dir" in kwargs: + if "load_dir" not in kwargs: if app.mod_stack: task.load_dir = relpath( Path(app.mod_stack[-1].__file__).parent, self.root_dir