From 93543573519510c694d4a1c884608a4a7ef8d677 Mon Sep 17 00:00:00 2001 From: "Andrew S. Rosen" Date: Fri, 29 Dec 2023 10:42:46 -0800 Subject: [PATCH] Guard against `all` name (#1437) --- src/quacc/wflow_tools/customizers.py | 2 ++ tests/core/wflow/test_customizers.py | 3 +++ 2 files changed, 5 insertions(+) diff --git a/src/quacc/wflow_tools/customizers.py b/src/quacc/wflow_tools/customizers.py index b9a51b291e..73e65de82f 100644 --- a/src/quacc/wflow_tools/customizers.py +++ b/src/quacc/wflow_tools/customizers.py @@ -122,6 +122,8 @@ def customize_funcs( funcs_dict = dict(zip(names, funcs)) + if "all" in names: + raise ValueError("Invalid function name: 'all' is a reserved name.") if bad_decorator_keys := [k for k in decorators if k not in names and k != "all"]: raise ValueError( f"Invalid decorator keys: {bad_decorator_keys}. " f"Valid keys are: {names}" diff --git a/tests/core/wflow/test_customizers.py b/tests/core/wflow/test_customizers.py index a4cd808773..aaa0075a5e 100644 --- a/tests/core/wflow/test_customizers.py +++ b/tests/core/wflow/test_customizers.py @@ -30,3 +30,6 @@ def mult(a, b=1, c=2, d=2): with pytest.raises(ValueError): customize_funcs(["add", "mult"], [add, mult], parameters={"bad": {"b": 2}}) + + with pytest.raises(ValueError): + customize_funcs("all", [add], parameters={"all": {"b": 2}})