Skip to content

Commit

Permalink
type hint application wrapper monkeypatch
Browse files Browse the repository at this point in the history
ignore method assignment. Currently mypy cannot check this.
Related upstream issues:
  - python/mypy#2427
  - python/mypy#708
  • Loading branch information
deeplow committed Aug 16, 2022
1 parent f3d715f commit 2307c82
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions dangerzone/gui/__init__.py
Expand Up @@ -7,7 +7,7 @@

import click
import colorama
from PySide2 import QtCore, QtWidgets
from PySide2 import QtCore, QtGui, QtWidgets

from ..global_common import GlobalCommon
from .common import GuiCommon
Expand All @@ -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())
Expand All @@ -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()
Expand Down

0 comments on commit 2307c82

Please sign in to comment.