diff --git a/anki/utils.py b/anki/utils.py
index 1798f31e7..c82fdf413 100644
--- a/anki/utils.py
+++ b/anki/utils.py
@@ -20,7 +20,7 @@ import traceback
from contextlib import contextmanager
from hashlib import sha1
from html.entities import name2codepoint
-from typing import Any, Iterator, List, Optional, Tuple, Union
+from typing import Any, Iterable, Iterator, List, Optional, Tuple, Union
from anki.db import DB
from anki.lang import _, ngettext
@@ -41,7 +41,7 @@ timeTable = {
"hours": lambda n: ngettext("%s hour", "%s hours", n),
"minutes": lambda n: ngettext("%s minute", "%s minutes", n),
"seconds": lambda n: ngettext("%s second", "%s seconds", n),
- }
+}
inTimeTable = {
"years": lambda n: ngettext("in %s year", "in %s years", n),
@@ -50,7 +50,7 @@ inTimeTable = {
"hours": lambda n: ngettext("in %s hour", "in %s hours", n),
"minutes": lambda n: ngettext("in %s minute", "in %s minutes", n),
"seconds": lambda n: ngettext("in %s second", "in %s seconds", n),
- }
+}
def shortTimeFmt(type: str) -> str:
return {
@@ -68,7 +68,9 @@ def shortTimeFmt(type: str) -> str:
"seconds": _("%ss"),
}[type]
-def fmtTimeSpan(time: Union[int, float], pad: int = 0, point: int = 0, short: bool = False, inTime: bool = False, unit: int = 99) -> str:
+def fmtTimeSpan(time: Union[int, float], pad: int = 0, point: int = 0,
+ short: bool = False, inTime: bool = False,
+ unit: int = 99) -> str:
"Return a string representing a time span (eg '2 days')."
(type, point) = optimalPeriod(time, point, unit)
time = convertSecondsTo(time, type)
@@ -84,7 +86,8 @@ def fmtTimeSpan(time: Union[int, float], pad: int = 0, point: int = 0, short: bo
timestr = "%%%(a)d.%(b)df" % {'a': pad, 'b': point}
return locale.format_string(fmt % timestr, time)
-def optimalPeriod(time: Union[int, float], point: int, unit: int) -> Tuple[str, int]:
+def optimalPeriod(time: Union[int, float], point: int,
+ unit: int) -> Tuple[str, int]:
if abs(time) < 60 or unit < 1:
type = "seconds"
point -= 1
@@ -157,7 +160,7 @@ def stripHTMLMedia(s: str) -> str:
s = reMedia.sub(" \\1 ", s)
return stripHTML(s)
-def minimizeHTML(s) -> str:
+def minimizeHTML(s: str) -> str:
"Correct Qt's verbose bold/underline/etc."
s = re.sub('(.*?)', '\\1',
s)
@@ -167,7 +170,7 @@ def minimizeHTML(s) -> str:
'\\1', s)
return s
-def htmlToTextLine(s) -> str:
+def htmlToTextLine(s: str) -> str:
s = s.replace("
", " ")
s = s.replace("
", " ")
s = s.replace("