Skip to content

Commit

Permalink
Small type fixes for core
Browse files Browse the repository at this point in the history
- add simple missing type annotations
- suppress errors for untyped parts
  • Loading branch information
gycsaba96 authored and diegogangl committed Oct 15, 2024
1 parent 17781fc commit c059f8b
Show file tree
Hide file tree
Showing 9 changed files with 16 additions and 13 deletions.
2 changes: 1 addition & 1 deletion GTG/backends/backend_signals.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
# this program. If not, see <http://www.gnu.org/licenses/>.
# -----------------------------------------------------------------------------

from gi.repository import GObject, GLib
from gi.repository import GObject, GLib # type: ignore[import-untyped]

from GTG.core.borg import Borg

Expand Down
3 changes: 2 additions & 1 deletion GTG/core/borg.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
# You should have received a copy of the GNU General Public License along with
# this program. If not, see <http://www.gnu.org/licenses/>.
# -----------------------------------------------------------------------------
from typing import Dict, Any


class Borg():
Expand All @@ -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
2 changes: 1 addition & 1 deletion GTG/core/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 4 additions & 3 deletions GTG/core/keyring.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,12 @@
# this program. If not, see <http://www.gnu.org/licenses/>.
# -----------------------------------------------------------------------------

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

Expand Down Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion GTG/core/networkmanager.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down
2 changes: 1 addition & 1 deletion GTG/core/plugins/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__)
Expand Down
5 changes: 3 additions & 2 deletions GTG/core/plugins/engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion GTG/core/sorters.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
4 changes: 2 additions & 2 deletions GTG/core/timer.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@
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__)


class Timer(GObject.GObject):
__signal_type__ = (GObject.SignalFlags.RUN_FIRST,
None,
[])
[]) # type: ignore[var-annotated]

__gsignals__ = {'refresh': __signal_type__}

Expand Down

0 comments on commit c059f8b

Please sign in to comment.