From a56690bc0845300b8f4f50ba2ec76cc0f86fd14c Mon Sep 17 00:00:00 2001 From: Matt Krump <1036969+mkrump@users.noreply.github.com> Date: Thu, 30 Jul 2020 16:49:05 -0600 Subject: [PATCH 1/3] Turn on check_untyped_defs for aqt.webview --- qt/aqt/qt.py | 1 + qt/aqt/webview.py | 4 ++-- qt/mypy.ini | 2 ++ 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/qt/aqt/qt.py b/qt/aqt/qt.py index 9c5dffc0e..3ce6e2fca 100644 --- a/qt/aqt/qt.py +++ b/qt/aqt/qt.py @@ -13,6 +13,7 @@ from PyQt5.Qt import * # type: ignore from PyQt5.QtCore import * from PyQt5.QtCore import pyqtRemoveInputHook # pylint: disable=no-name-in-module from PyQt5.QtGui import * # type: ignore +from PyQt5.QtWebChannel import QWebChannel from PyQt5.QtWebEngineWidgets import * from PyQt5.QtWidgets import * diff --git a/qt/aqt/webview.py b/qt/aqt/webview.py index 88b5b3a40..8220e26d7 100644 --- a/qt/aqt/webview.py +++ b/qt/aqt/webview.py @@ -30,9 +30,9 @@ class AnkiWebPage(QWebEnginePage): self._setupBridge() self.open_links_externally = True - def _setupBridge(self): + def _setupBridge(self) -> None: class Bridge(QObject): - @pyqtSlot(str, result=str) + @pyqtSlot(str, result=str) # type: ignore def cmd(self, str): return json.dumps(self.onCmd(str)) diff --git a/qt/mypy.ini b/qt/mypy.ini index 9adcb3d1b..ed6253bc7 100644 --- a/qt/mypy.ini +++ b/qt/mypy.ini @@ -88,3 +88,5 @@ check_untyped_defs=true check_untyped_defs=true [mypy-aqt.modelchooser] check_untyped_defs=true +[mypy-aqt.webview] +check_untyped_defs=true From 7d8f8560600c2dea8293da2a10dcf049ac071acc Mon Sep 17 00:00:00 2001 From: Matt Krump <1036969+mkrump@users.noreply.github.com> Date: Thu, 30 Jul 2020 17:54:05 -0600 Subject: [PATCH 2/3] Turn on check_untyped_defs for aqt.addons --- qt/aqt/addons.py | 4 ++-- qt/mypy.ini | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/qt/aqt/addons.py b/qt/aqt/addons.py index b5e534cce..5773e8e28 100644 --- a/qt/aqt/addons.py +++ b/qt/aqt/addons.py @@ -179,7 +179,7 @@ class AddonManager: sys.path.insert(0, self.addonsFolder()) # in new code, you may want all_addon_meta() instead - def allAddons(self): + def allAddons(self) -> List[str]: l = [] for d in os.listdir(self.addonsFolder()): path = self.addonsFolder(d) @@ -188,7 +188,7 @@ class AddonManager: l.append(d) l.sort() if os.getenv("ANKIREVADDONS", ""): - l = reversed(l) + l = list(reversed(l)) return l def all_addon_meta(self) -> Iterable[AddonMeta]: diff --git a/qt/mypy.ini b/qt/mypy.ini index ed6253bc7..04415f4cd 100644 --- a/qt/mypy.ini +++ b/qt/mypy.ini @@ -90,3 +90,5 @@ check_untyped_defs=true check_untyped_defs=true [mypy-aqt.webview] check_untyped_defs=true +[mypy-aqt.addons] +check_untyped_defs=true From 10f2f9c037196f5389d784dccc80907005123506 Mon Sep 17 00:00:00 2001 From: Matt Krump <1036969+mkrump@users.noreply.github.com> Date: Thu, 30 Jul 2020 17:54:42 -0600 Subject: [PATCH 3/3] Turn on check_untyped_defs for aqt.emptycards --- qt/aqt/emptycards.py | 4 ++-- qt/mypy.ini | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/qt/aqt/emptycards.py b/qt/aqt/emptycards.py index 773d1c650..55b02fb6b 100644 --- a/qt/aqt/emptycards.py +++ b/qt/aqt/emptycards.py @@ -85,10 +85,10 @@ class EmptyCardsDialog(QDialog): self.mw.taskman.run_in_background(delete, on_done) - def _delete_cards(self, keep_notes): + def _delete_cards(self, keep_notes: bool) -> int: to_delete = [] + note: NoteWithEmptyCards for note in self.report.notes: - note: NoteWithEmptyCards = note if keep_notes and note.will_delete_note: # leave first card to_delete.extend(note.card_ids[1:]) diff --git a/qt/mypy.ini b/qt/mypy.ini index 04415f4cd..31cf898b2 100644 --- a/qt/mypy.ini +++ b/qt/mypy.ini @@ -92,3 +92,5 @@ check_untyped_defs=true check_untyped_defs=true [mypy-aqt.addons] check_untyped_defs=true +[mypy-aqt.emptycards] +check_untyped_defs=true