Add types for eventfilter/quitter

This commit is contained in:
Florian Bruhin 2020-01-13 08:07:16 +01:00
parent 29e0127034
commit 9d4de0163a
3 changed files with 13 additions and 8 deletions

View File

@ -87,6 +87,14 @@ disallow_incomplete_defs = True
disallow_untyped_defs = True
disallow_incomplete_defs = True
[mypy-qutebrowser.misc.backendproblem]
disallow_untyped_defs = True
disallow_incomplete_defs = True
[mypy-qutebrowser.misc.eventfilter]
disallow_untyped_defs = True
disallow_incomplete_defs = True
[mypy-qutebrowser.commands.cmdutils]
disallow_untyped_defs = True
disallow_incomplete_defs = True
@ -127,10 +135,6 @@ disallow_incomplete_defs = True
disallow_untyped_defs = True
disallow_incomplete_defs = True
[mypy-qutebrowser.misc.backendproblem]
disallow_untyped_defs = True
disallow_incomplete_defs = True
[mypy-qutebrowser.mainwindow.statusbar.command]
disallow_untyped_defs = True
disallow_incomplete_defs = True

View File

@ -47,11 +47,11 @@ class EventFilter(QObject):
QEvent.ShortcutOverride: self._handle_key_event,
}
def install(self):
def install(self) -> None:
QApplication.instance().installEventFilter(self)
@pyqtSlot()
def shutdown(self):
def shutdown(self) -> None:
QApplication.instance().removeEventFilter(self)
def _handle_key_event(self, event: QKeyEvent) -> bool:
@ -105,7 +105,8 @@ class EventFilter(QObject):
raise
def init():
def init() -> None:
"""Initialize the global EventFilter instance."""
event_filter = EventFilter(parent=QApplication.instance())
event_filter.install()
quitter.instance.shutting_down.connect(event_filter.shutdown)

View File

@ -265,7 +265,7 @@ class Quitter(QObject):
# segfaults.
QTimer.singleShot(0, functools.partial(self._shutdown_3, status))
def _shutdown_3(self, status):
def _shutdown_3(self, status: int) -> None:
"""Finally shut down the QApplication."""
log.destroy.debug("Now calling QApplication::exit.")
if 'debug-exit' in objects.debug_flags: