Skip to content

Commit

Permalink
Remove empty elements from comma-separated list
Browse files Browse the repository at this point in the history
Updates the list parsing in Configuration to remove empty strings
from the comma-separated list. This will allow creating a single-
element list by appending a `,` after the element.

Refs: NOAA-EMC/global-workflow#2795
  • Loading branch information
WalterKolczynski-NOAA committed Jul 31, 2024
1 parent 264e8f3 commit 7174ac4
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/wxflow/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ def cast_as_dtype(string: str) -> Union[str, int, float, bool, Any]:

if ',' in string:
# Convert comma-separated list to python list
return [cast_as_dtype(elem.strip()) for elem in string.split(',')]
return [cast_as_dtype(elem.strip()) for elem in string.split(',') if elem.strip() != '']

def _cast_or_not(to_type: Any, string: str):
try:
Expand Down
2 changes: 1 addition & 1 deletion tests/test_configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
export SOME_BOOL6=.F.
export SOME_LIST1="3, 15, -999"
export SOME_LIST2="0.2,3.5,-9999."
export SOME_LIST3="20221225, 202212251845"
export SOME_LIST3="20221225, 202212251845,"
export SOME_LIST4="YES, .false., .T."
export SOME_LIST5="0.2, test_str, 15, 20221225, NO"
"""
Expand Down

0 comments on commit 7174ac4

Please sign in to comment.