From d58529f4cce0f6fbf9aeda0b1796df17a2f5c0f1 Mon Sep 17 00:00:00 2001 From: relikd Date: Mon, 24 Oct 2022 21:34:27 +0200 Subject: [PATCH] fix: most_used_key with empty list --- lektor_groupby/util.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lektor_groupby/util.py b/lektor_groupby/util.py index 2689ea7..1bdb5c5 100644 --- a/lektor_groupby/util.py +++ b/lektor_groupby/util.py @@ -16,7 +16,7 @@ def report_config_error(key: str, field: str, val: str, e: Exception) -> None: def most_used_key(keys: List[str]) -> str: ''' Find string with most occurrences. ''' if len(keys) < 3: - return keys[0] # TODO: first vs last occurrence + return keys[0] if keys else '' # TODO: first vs last occurrence best_count = 0 best_key = '' tmp = {} # type: Dict[str, int]