Skip to content

Commit

Permalink
Guard against all name (#1437)
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrew-S-Rosen authored Dec 29, 2023
1 parent 9a93a6d commit 9354357
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/quacc/wflow_tools/customizers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
Expand Down
3 changes: 3 additions & 0 deletions tests/core/wflow/test_customizers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}})

0 comments on commit 9354357

Please sign in to comment.