fix: most_used_key with empty list

This commit is contained in:
relikd
2022-10-24 21:34:27 +02:00
parent 03475e3e5a
commit d58529f4cc

View File

@@ -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]