From c059f8b5acc5f5cfae677c356201e09bb25b4edc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Csaba=20Gy=C3=B6rgyi?= Date: Sun, 6 Oct 2024 13:01:56 +0200 Subject: [PATCH] Small type fixes for core - add simple missing type annotations - suppress errors for untyped parts --- GTG/backends/backend_signals.py | 2 +- GTG/core/borg.py | 3 ++- GTG/core/filters.py | 2 +- GTG/core/keyring.py | 7 ++++--- GTG/core/networkmanager.py | 2 +- GTG/core/plugins/api.py | 2 +- GTG/core/plugins/engine.py | 5 +++-- GTG/core/sorters.py | 2 +- GTG/core/timer.py | 4 ++-- 9 files changed, 16 insertions(+), 13 deletions(-) diff --git a/GTG/backends/backend_signals.py b/GTG/backends/backend_signals.py index f123ca648e..270648df73 100644 --- a/GTG/backends/backend_signals.py +++ b/GTG/backends/backend_signals.py @@ -16,7 +16,7 @@ # this program. If not, see . # ----------------------------------------------------------------------------- -from gi.repository import GObject, GLib +from gi.repository import GObject, GLib # type: ignore[import-untyped] from GTG.core.borg import Borg diff --git a/GTG/core/borg.py b/GTG/core/borg.py index 2bd540e9df..fde0c689c2 100644 --- a/GTG/core/borg.py +++ b/GTG/core/borg.py @@ -15,6 +15,7 @@ # You should have received a copy of the GNU General Public License along with # this program. If not, see . # ----------------------------------------------------------------------------- +from typing import Dict, Any class Borg(): @@ -23,7 +24,7 @@ class Borg(): the same state (just inherit this class to have it working) """ - _borg_state = {} + _borg_state: Dict[str,Any] = {} def __init__(self): self.__dict__ = self._borg_state diff --git a/GTG/core/filters.py b/GTG/core/filters.py index 97a2f285bd..8101c17912 100644 --- a/GTG/core/filters.py +++ b/GTG/core/filters.py @@ -18,7 +18,7 @@ """Filters for tags and tasks""" -from gi.repository import Gtk +from gi.repository import Gtk # type: ignore[import-untyped] from GTG.core.tags import Tag from GTG.core.tasks import Task, Status from GTG.core import search diff --git a/GTG/core/keyring.py b/GTG/core/keyring.py index fc38b4e8d5..147382ef91 100644 --- a/GTG/core/keyring.py +++ b/GTG/core/keyring.py @@ -16,11 +16,12 @@ # this program. If not, see . # ----------------------------------------------------------------------------- -import gi +from typing import Type +import gi # type: ignore[import-untyped] import logging try: gi.require_version('Secret', '1') - from gi.repository import Secret + from gi.repository import Secret # type: ignore[import-untyped] except (ValueError, ImportError): Secret = None @@ -118,7 +119,7 @@ def get_password(self, key): if Secret is not None: - Keyring = SecretKeyring + Keyring: Type[SecretKeyring|GNOMEKeyring|FallbackKeyring] = SecretKeyring elif GnomeKeyring is not None: Keyring = GNOMEKeyring else: diff --git a/GTG/core/networkmanager.py b/GTG/core/networkmanager.py index 13daaca6d8..2c93407256 100755 --- a/GTG/core/networkmanager.py +++ b/GTG/core/networkmanager.py @@ -19,7 +19,7 @@ """ Communicate with Network Manager """ -from gi.repository import Gio +from gi.repository import Gio # type: ignore[import-untyped] def is_connection_up(): diff --git a/GTG/core/plugins/api.py b/GTG/core/plugins/api.py index 01e898e522..ac8fc6f71e 100644 --- a/GTG/core/plugins/api.py +++ b/GTG/core/plugins/api.py @@ -19,7 +19,7 @@ import os import pickle import logging -from gi.repository import GLib +from gi.repository import GLib # type: ignore[import-untyped] from GTG.core.dirs import plugin_configuration_dir log = logging.getLogger(__name__) diff --git a/GTG/core/plugins/engine.py b/GTG/core/plugins/engine.py index 500462e26d..c5f1fddeff 100644 --- a/GTG/core/plugins/engine.py +++ b/GTG/core/plugins/engine.py @@ -20,7 +20,8 @@ import inspect import os import logging -from gi.repository import GLib +from typing import List +from gi.repository import GLib # type: ignore[import-untyped] from GTG.core.dirs import PLUGIN_DIRS from GTG.core.borg import Borg @@ -39,7 +40,7 @@ class Plugin(): error = False # True if the plugin is actually loaded and running. _active = False - missing_modules = [] + missing_modules: List[str] = [] missing_dbus = [] def __init__(self, info, module_paths): diff --git a/GTG/core/sorters.py b/GTG/core/sorters.py index ef77cdd8b7..1831b8a999 100644 --- a/GTG/core/sorters.py +++ b/GTG/core/sorters.py @@ -18,7 +18,7 @@ """Sorters for tags and tasks.""" -from gi.repository import Gtk +from gi.repository import Gtk # type: ignore[import-untyped] from GTG.core.tasks import Task def unwrap(row, expected_type): diff --git a/GTG/core/timer.py b/GTG/core/timer.py index aaa40be317..d0e4399021 100644 --- a/GTG/core/timer.py +++ b/GTG/core/timer.py @@ -22,7 +22,7 @@ import re import logging -from gi.repository import GObject, GLib, Gio +from gi.repository import GObject, GLib, Gio # type: ignore[import-untyped] log = logging.getLogger(__name__) @@ -30,7 +30,7 @@ class Timer(GObject.GObject): __signal_type__ = (GObject.SignalFlags.RUN_FIRST, None, - []) + []) # type: ignore[var-annotated] __gsignals__ = {'refresh': __signal_type__}