From 358922b09b91e97a30fafab848d604534b0b7e49 Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Sun, 10 May 2020 15:29:10 +0200 Subject: [PATCH] lib/ui: fix human_list for lists with one item --- passbook/lib/utils/ui.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/passbook/lib/utils/ui.py b/passbook/lib/utils/ui.py index b04aec2d4..f898e086a 100644 --- a/passbook/lib/utils/ui.py +++ b/passbook/lib/utils/ui.py @@ -1,8 +1,11 @@ """passbook UI utils""" +from typing import Any, List -def human_list(_list) -> str: +def human_list(_list: List[Any]) -> str: """Convert a list of items into 'a, b or c'""" last_item = _list.pop() + if len(_list) < 1: + return last_item result = ", ".join(_list) return "%s or %s" % (result, last_item)