Skip to content

Commit d2379f1

Browse files
committed
address feedback: narrow guard to empty string and add regression tests
- Update decompress_list to check specifically for "" as a guard. - Add test/unit/test_util.py with regression tests for empty input.
1 parent b06b515 commit d2379f1

2 files changed

Lines changed: 10 additions & 1 deletion

File tree

metaflow/util.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,7 @@ def compress_list(lst, separator=",", rangedelim=":", zlibmarker="!", zlibmin=50
385385
def decompress_list(lststr, separator=",", rangedelim=":", zlibmarker="!"):
386386
# Handle the empty-list round-trip: compress_list([]) == "" so we must
387387
# return [] without touching lststr[0] (which would raise IndexError).
388-
if not lststr:
388+
if lststr == "":
389389
return []
390390
# Three input modes:
391391
if lststr[0] == zlibmarker:

test/unit/test_util.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
from metaflow.util import compress_list, decompress_list
2+
3+
def test_compress_decompress_empty_list():
4+
# round-trip must not raise and must return []
5+
assert decompress_list(compress_list([])) == []
6+
7+
def test_decompress_empty_string():
8+
# direct empty-string input
9+
assert decompress_list("") == []

0 commit comments

Comments
 (0)