mirror of
https://github.com/freedomofpress/dangerzone.git
synced 2025-04-29 10:12:38 +02:00
type hint application wrapper monkeypatch
ignore method assignment. Currently mypy cannot check this. Related upstream issues: - https://github.com/python/mypy/issues/2427 - https://github.com/python/mypy/issues/708
This commit is contained in:
parent
bc7188eb4d
commit
75ce244195
1 changed files with 5 additions and 4 deletions
|
@ -8,7 +8,7 @@ from typing import Dict, Optional
|
||||||
|
|
||||||
import click
|
import click
|
||||||
import colorama
|
import colorama
|
||||||
from PySide2 import QtCore, QtWidgets
|
from PySide2 import QtCore, QtGui, QtWidgets
|
||||||
|
|
||||||
from ..global_common import GlobalCommon
|
from ..global_common import GlobalCommon
|
||||||
from .common import GuiCommon
|
from .common import GuiCommon
|
||||||
|
@ -30,9 +30,10 @@ class ApplicationWrapper(QtCore.QObject):
|
||||||
|
|
||||||
self.original_event = self.app.event
|
self.original_event = self.app.event
|
||||||
|
|
||||||
def monkeypatch_event(event: QtCore.QEvent) -> bool:
|
def monkeypatch_event(arg__1: QtCore.QEvent) -> bool:
|
||||||
|
event = arg__1 # oddly Qt calls internally event by "arg__1"
|
||||||
# In macOS, handle the file open event
|
# In macOS, handle the file open event
|
||||||
if event.type() == QtCore.QEvent.FileOpen:
|
if isinstance(event, QtGui.QFileOpenEvent):
|
||||||
# Skip file open events in dev mode
|
# Skip file open events in dev mode
|
||||||
if not hasattr(sys, "dangerzone_dev"):
|
if not hasattr(sys, "dangerzone_dev"):
|
||||||
self.document_selected.emit(event.file())
|
self.document_selected.emit(event.file())
|
||||||
|
@ -43,7 +44,7 @@ class ApplicationWrapper(QtCore.QObject):
|
||||||
|
|
||||||
return self.original_event(event)
|
return self.original_event(event)
|
||||||
|
|
||||||
self.app.event = monkeypatch_event
|
self.app.event = monkeypatch_event # type: ignore [assignment]
|
||||||
|
|
||||||
|
|
||||||
@click.command()
|
@click.command()
|
||||||
|
|
Loading…
Reference in a new issue