From a67e1bc94f5f8c86fbc3caade6a7b1ba3383f83b Mon Sep 17 00:00:00 2001 From: deeplow Date: Thu, 4 Aug 2022 16:43:53 +0100 Subject: [PATCH] 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 --- dangerzone/gui/__init__.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/dangerzone/gui/__init__.py b/dangerzone/gui/__init__.py index 758094f73..677bea8e2 100644 --- a/dangerzone/gui/__init__.py +++ b/dangerzone/gui/__init__.py @@ -7,7 +7,7 @@ import click import colorama -from PySide2 import QtCore, QtWidgets +from PySide2 import QtCore, QtWidgets, QtGui from ..global_common import GlobalCommon from .common import GuiCommon @@ -29,9 +29,10 @@ def __init__(self) -> None: 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 - if event.type() == QtCore.QEvent.FileOpen: + if isinstance(event, QtGui.QFileOpenEvent): # Skip file open events in dev mode if not hasattr(sys, "dangerzone_dev"): self.document_selected.emit(event.file()) @@ -42,7 +43,7 @@ def monkeypatch_event(event: QtCore.QEvent) -> bool: return self.original_event(event) - self.app.event = monkeypatch_event + self.app.event = monkeypatch_event # type: ignore [assignment] @click.command()