Turn on check_untyped_defs for aqt.main

This commit is contained in:
Matt Krump 2020-07-31 20:27:54 -06:00
parent a8139ebb40
commit 83449e35ad
2 changed files with 11 additions and 9 deletions

View file

@ -14,7 +14,7 @@ import weakref
import zipfile import zipfile
from argparse import Namespace from argparse import Namespace
from threading import Thread from threading import Thread
from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple from typing import Any, Callable, Dict, List, Optional, Sequence, TextIO, Tuple, cast
import anki import anki
import aqt import aqt
@ -185,9 +185,9 @@ class AnkiQt(QMainWindow):
onClose = pyqtSignal() onClose = pyqtSignal()
closeFires = True closeFires = True
def closeEvent(self, evt): def closeEvent(self, evt: QCloseEvent) -> None:
if self.closeFires: if self.closeFires:
self.onClose.emit() self.onClose.emit() # type: ignore
evt.accept() evt.accept()
def closeWithoutQuitting(self): def closeWithoutQuitting(self):
@ -924,10 +924,10 @@ title="%s" %s>%s</button>""" % (
# Tools # Tools
########################################################################## ##########################################################################
def raiseMain(self): def raiseMain(self) -> bool:
if not self.app.activeWindow(): if not self.app.activeWindow():
# make sure window is shown # make sure window is shown
self.setWindowState(self.windowState() & ~Qt.WindowMinimized) self.setWindowState(self.windowState() & ~Qt.WindowMinimized) # type: ignore
return True return True
def setupStyle(self) -> None: def setupStyle(self) -> None:
@ -1412,7 +1412,7 @@ will be lost. Continue?"""
gui_hooks.debug_console_will_show(d) gui_hooks.debug_console_will_show(d)
d.show() d.show()
def _captureOutput(self, on): def _captureOutput(self, on: bool) -> None:
mw = self mw = self
class Stream: class Stream:
@ -1423,7 +1423,7 @@ will be lost. Continue?"""
self._output = "" self._output = ""
self._oldStderr = sys.stderr self._oldStderr = sys.stderr
self._oldStdout = sys.stdout self._oldStdout = sys.stdout
s = Stream() s = cast(TextIO, Stream())
sys.stderr = s sys.stderr = s
sys.stdout = s sys.stdout = s
else: else:
@ -1547,8 +1547,8 @@ will be lost. Continue?"""
for action in self.findChildren(QAction): for action in self.findChildren(QAction):
action.setStatusTip("") action.setStatusTip("")
def onMacMinimize(self): def onMacMinimize(self) -> None:
self.setWindowState(self.windowState() | Qt.WindowMinimized) self.setWindowState(self.windowState() | Qt.WindowMinimized) # type: ignore
# Single instance support # Single instance support
########################################################################## ##########################################################################

View file

@ -96,3 +96,5 @@ check_untyped_defs=true
check_untyped_defs=true check_untyped_defs=true
[mypy-aqt.profiles] [mypy-aqt.profiles]
check_untyped_defs=true check_untyped_defs=true
[mypy-aqt.main]
check_untyped_defs=true