Skip to content

Commit 519da18

Browse files
committed
fix: correct falsy-value handling in list utility helpers
Signed-off-by: Rishi Jat <rishijat098@gmail.com>
1 parent 20fbd3b commit 519da18

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

trestle/common/list_utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ def deep_set(dic: Dict[str, Any], path: List[str], value: Any, pop_if_none: bool
144144
for node in path[:-1]:
145145
dic[node] = dic.get(node, {})
146146
dic = dic[node]
147-
if value or not pop_if_none:
147+
if value is not None or not pop_if_none:
148148
dic[path[-1]] = value
149149
else:
150150
dic.pop(path[-1], None)
@@ -185,7 +185,7 @@ def deep_append(dic: Dict[str, Any], path: List[str], value: Any) -> None:
185185

186186
def set_or_pop(dic: Dict[str, Any], key: str, value: Any) -> None:
187187
"""Set if value is non-empty list or not None otherwise remove."""
188-
if value:
188+
if value is not None:
189189
dic[key] = value
190190
else:
191191
dic.pop(key, None)

0 commit comments

Comments
 (0)