Merge pull request #720 from mkrump/help-wanted-4-add-type-hints-6

Turn on check_untyped_defs for aqt.webview, aqt.addons and aqt.emptycards.
This commit is contained in:
Damien Elmes 2020-07-31 14:08:48 +10:00 committed by GitHub
commit bcc35c1822
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 13 additions and 6 deletions

View File

@ -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]:

View File

@ -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:])

View File

@ -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 *

View File

@ -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))

View File

@ -88,5 +88,11 @@ check_untyped_defs=true
check_untyped_defs=true
[mypy-aqt.modelchooser]
check_untyped_defs=true
[mypy-aqt.webview]
check_untyped_defs=true
[mypy-aqt.addons]
check_untyped_defs=true
[mypy-aqt.emptycards]
check_untyped_defs=true
[mypy-aqt.profiles]
check_untyped_defs=true