Fix mypy and import errors in overview.py and stats.py

This commit is contained in:
Al Ali 2025-06-16 21:14:08 +02:00
parent 5ecdd310e5
commit 2c45175cec

View file

@ -311,13 +311,13 @@ select count() from cards where did in %s and queue in ({QUEUE_TYPE_REV},{QUEUE_
and due = ?""" and due = ?"""
% self._limit(), % self._limit(),
self.col.sched.today + 1, self.col.sched.today + 1,
) )
tomorrow = "%d cards" % tomorrow tomorrow = "%d cards" % tomorrow
self._line(i, "Due tomorrow", tomorrow) self._line(i, "Due tomorrow", tomorrow)
return self._lineTbl(i) return self._lineTbl(i)
def _due( def _due(
self, start: int | None = None, end: int | None = None, chunk: int = 1 self, start: int | None = None, end: int | None = None, chunk: int = 1
) -> Any: ) -> Any:
lim = "" lim = ""
if start is not None: if start is not None:
@ -436,13 +436,13 @@ group by day order by day"""
return self._section(txt1) + self._section(txt2) return self._section(txt1) + self._section(txt2)
def _ansInfo( def _ansInfo(
self, self,
totd: list[tuple[int, float]], totd: list[tuple[int, float]],
studied: int, studied: int,
first: int, first: int,
unit: str, unit: str,
convHours: bool = False, convHours: bool = False,
total: int | None = None, total: int | None = None,
) -> tuple[str, int]: ) -> tuple[str, int]:
assert totd assert totd
tot = totd[-1][1] tot = totd[-1][1]
@ -457,7 +457,7 @@ group by day order by day"""
"<b>%(pct)d%%</b> (%(x)s of %(y)s)" "<b>%(pct)d%%</b> (%(x)s of %(y)s)"
% dict(x=studied, y=period, pct=studied / float(period) * 100), % dict(x=studied, y=period, pct=studied / float(period) * 100),
bold=False, bold=False,
) )
if convHours: if convHours:
tunit = "hours" tunit = "hours"
else: else:
@ -484,9 +484,9 @@ group by day order by day"""
return self._lineTbl(i), int(tot) return self._lineTbl(i), int(tot)
def _splitRepData( def _splitRepData(
self, self,
data: list[tuple[Any, ...]], data: list[tuple[Any, ...]],
spec: Sequence[tuple[int, str, str]], spec: Sequence[tuple[int, str, str]],
) -> tuple[list[dict[str, Any]], list[tuple[Any, Any]]]: ) -> tuple[list[dict[str, Any]], list[tuple[Any, Any]]]:
sep: dict[int, Any] = {} sep: dict[int, Any] = {}
totcnt = {} totcnt = {}
@ -593,7 +593,7 @@ group by day order by day"""
tf, tf,
tf, tf,
tf, tf,
) )
def _daysStudied(self) -> Any: def _daysStudied(self) -> Any:
lims = [] lims = []
@ -617,7 +617,7 @@ from revlog %s
group by day order by day)""" group by day order by day)"""
% lim, % lim,
self.col.sched.day_cutoff, self.col.sched.day_cutoff,
) )
assert ret assert ret
return ret return ret
@ -677,7 +677,7 @@ group by grp
order by grp""" order by grp"""
% (self._limit(), lim), % (self._limit(), lim),
chunk, chunk,
) )
] ]
return ( return (
data data
@ -759,11 +759,11 @@ select count(), avg(ivl), max(ivl) from cards where did in %s and queue = {QUEUE
% dict(pct=pct, good=good, tot=tot) % dict(pct=pct, good=good, tot=tot)
) )
return ( return (
""" """
<center><table width=%dpx><tr><td width=50></td><td align=center>""" <center><table width=%dpx><tr><td width=50></td><td align=center>"""
% self.width % self.width
+ "</td><td align=center>".join(i) + "</td><td align=center>".join(i)
+ "</td></tr></table></center>" + "</td></tr></table></center>"
) )
def _eases(self) -> Any: def _eases(self) -> Any:
@ -892,12 +892,12 @@ group by hour having count() > 30 order by hour"""
div = self._cards() div = self._cards()
d = [] d = []
for c, (t, col) in enumerate( for c, (t, col) in enumerate(
( (
("Mature", colMature), ("Mature", colMature),
("Young+Learn", colYoung), ("Young+Learn", colYoung),
("Unseen", colUnseen), ("Unseen", colUnseen),
("Suspended+Buried", colSusp), ("Suspended+Buried", colSusp),
) )
): ):
d.append(dict(data=div[c], label=f"{t}: {div[c]}", color=col)) d.append(dict(data=div[c], label=f"{t}: {div[c]}", color=col))
# text data # text data
@ -987,14 +987,14 @@ from cards where did in %s"""
###################################################################### ######################################################################
def _graph( def _graph(
self, self,
id: str, id: str,
data: Any, data: Any,
conf: Any | None = None, conf: Any | None = None,
type: str = "bars", type: str = "bars",
xunit: int = 1, xunit: int = 1,
ylabel: str = "Cards", ylabel: str = "Cards",
ylabel2: str = "", ylabel2: str = "",
) -> str: ) -> str:
if conf is None: if conf is None:
conf = {} conf = {}