From 0cf16d1eefac3c6b1b434111b00e372e352438f5 Mon Sep 17 00:00:00 2001 From: Dominik Jain Date: Tue, 31 Mar 2026 15:36:04 +0200 Subject: [PATCH] Circumvent mypy unreachable code error --- src/serena/dashboard.py | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/src/serena/dashboard.py b/src/serena/dashboard.py index 640bee51..34927596 100644 --- a/src/serena/dashboard.py +++ b/src/serena/dashboard.py @@ -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!