Circumvent mypy unreachable code error

This commit is contained in:
Dominik Jain authored and Dominik Jain committed 2026-03-31 15:36:18 +02:00
1 parent 0bab0125d7
commit 0cf16d1eef
1 file changed
+14 -15
+14 -15
View File
@@ -778,22 +778,21 @@ class SerenaDashboardViewer:
Sets the NSApplication activation policy to Regular (shows in dock) or
Accessory (hides from dock). No-op on other platforms.
"""
if sys.platform != "darwin":
return
from AppKit import (
NSApplication,
NSApplicationActivationPolicyAccessory,
NSApplicationActivationPolicyRegular,
)
if sys.platform == "darwin":
from AppKit import (
NSApplication,
NSApplicationActivationPolicyAccessory,
NSApplicationActivationPolicyRegular,
)
ns_app = NSApplication.sharedApplication()
policy = NSApplicationActivationPolicyRegular if visible else NSApplicationActivationPolicyAccessory
ns_app.setActivationPolicy_(policy)
if visible:
# setActivationPolicy_ alone is not enough at runtime; unhide_ fires
# the full applicationWillUnhide:/applicationDidUnhide: cycle, which
# is what actually restores the dock icon and brings windows forward.
ns_app.unhide_(None)
ns_app = NSApplication.sharedApplication()
policy = NSApplicationActivationPolicyRegular if visible else NSApplicationActivationPolicyAccessory
ns_app.setActivationPolicy_(policy)
if visible:
# setActivationPolicy_ alone is not enough at runtime; unhide_ fires
# the full applicationWillUnhide:/applicationDidUnhide: cycle, which
# is what actually restores the dock icon and brings windows forward.
ns_app.unhide_(None)
def _start_tray(self) -> None:
# import pystray locally, because the import fails when there is no display!