From 80e49e770f40a402d0b8d21eecee55e31a21a2d6 Mon Sep 17 00:00:00 2001 From: Al Ali Date: Mon, 16 Jun 2025 23:05:12 +0200 Subject: [PATCH] Fix Python 3.9 compatibility and layout check --- pylib/anki/anki_helpers/activity.py | 6 ++++-- qt/aqt/overview.py | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/pylib/anki/anki_helpers/activity.py b/pylib/anki/anki_helpers/activity.py index 002314031..8dd5e5cd0 100644 --- a/pylib/anki/anki_helpers/activity.py +++ b/pylib/anki/anki_helpers/activity.py @@ -1,7 +1,9 @@ from collections import defaultdict -from typing import Dict +from typing import Dict, Union from anki.collection import Collection -def analyze_activity(col: Collection, days: int = 30) -> dict[str, int | float]: + +def analyze_activity(col: Collection, days: int = 30) -> dict[str, Union[int, float]]: + day_cutoff = col.sched.day_cutoff start_time = day_cutoff - days * 86400 start_ts = start_time * 1000 # ms diff --git a/qt/aqt/overview.py b/qt/aqt/overview.py index b577922e5..cec682c00 100644 --- a/qt/aqt/overview.py +++ b/qt/aqt/overview.py @@ -70,7 +70,7 @@ class Overview: layout = self.web.layout() if layout is not None: layout = self.web.layout() - if hasattr(layout, "insertWidget"): + if layout is not None and hasattr(layout, "insertWidget"): layout.insertWidget(0, streak_widget) def show(self) -> None: