Skip to content

Commit

Permalink
chore: ignore all type errors for the optional AppIndicator deps
Browse files Browse the repository at this point in the history
  • Loading branch information
friday committed Apr 21, 2024
1 parent 86b6e02 commit 6405004
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions ulauncher/ui/AppIndicator.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# Ignore type errors for the AppIndicator deps
# mypy: disable-error-code="attr-defined"
import logging
from pathlib import Path
from typing import Any, Callable
Expand All @@ -11,22 +13,22 @@
# Only XApp supports activating the launcher on left click and showing the menu on right click
try:
gi.require_version("XApp", "1.0")
from gi.repository import XApp # type: ignore[attr-defined]
from gi.repository import XApp

# Older versions of XApp doesn't have StatusIcon
assert hasattr(XApp, "StatusIcon")
AyatanaIndicator = None
except (AssertionError, ImportError, ValueError):
XApp = None
XApp = None # type: ignore[assignment, unused-ignore]
try:
gi.require_version("AppIndicator3", "0.1")
from gi.repository import AppIndicator3 # type: ignore[attr-defined, unused-ignore]
from gi.repository import AppIndicator3

AyatanaIndicator = AppIndicator3
except (ImportError, ValueError):
try:
gi.require_version("AyatanaAppIndicator3", "0.1")
from gi.repository import AyatanaAppIndicator3 # type: ignore[attr-defined, unused-ignore]
from gi.repository import AyatanaAppIndicator3

AyatanaIndicator = AyatanaAppIndicator3
except (ImportError, ValueError):
Expand Down Expand Up @@ -110,4 +112,5 @@ def switch(self, status: bool = False) -> None:
if XApp:
self._indicator.set_visible(status)
elif AyatanaIndicator:
self._indicator.set_status(getattr(AyatanaIndicator.IndicatorStatus, "ACTIVE" if status else "PASSIVE"))
status = getattr(AyatanaIndicator.IndicatorStatus, "ACTIVE" if status else "PASSIVE")
self._indicator.set_status(status)

0 comments on commit 6405004

Please sign in to comment.