From 9a778541b5697eb7b420c7b2def2dbc665932f21 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philipp=20H=C3=B6rist?= Date: Tue, 11 Sep 2018 00:16:46 +0200 Subject: [PATCH] Add annotations for modules/__init__.py --- gajim/common/modules/__init__.py | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/gajim/common/modules/__init__.py b/gajim/common/modules/__init__.py index 09de54712..8de7f6a1f 100644 --- a/gajim/common/modules/__init__.py +++ b/gajim/common/modules/__init__.py @@ -13,6 +13,9 @@ # along with Gajim. If not, see . import logging +from typing import List # noqa +from typing import Dict # noqa +from typing import Any # noqa from importlib import import_module from pathlib import Path from unittest.mock import MagicMock @@ -21,8 +24,8 @@ log = logging.getLogger('gajim.c.m') ZEROCONF_MODULES = ['adhoc_commands', 'receipts', 'discovery'] -imported_modules = [] -_modules = {} +imported_modules = [] # type: List[tuple] +_modules = {} # type: Dict[str, Dict[str, Any]] for file in Path(__file__).parent.iterdir(): if file.stem == '__init__': @@ -40,30 +43,30 @@ for file in Path(__file__).parent.iterdir(): class ModuleMock: - def __init__(self, name): + def __init__(self, name: str) -> None: self._name = name # HTTPUpload, .. self.available = False # Blocking - self.blocked = [] + self.blocked = [] # type: List[Any] # Privacy Lists - self.blocked_contacts = [] - self.blocked_groups = [] + self.blocked_contacts = [] # type: List[Any] + self.blocked_groups = [] # type: List[Any] self.blocked_all = False # Delimiter self.delimiter = '::' # Bookmarks - self.bookmarks = {} + self.bookmarks = {} # type: Dict[Any, Any] # Various Modules self.supported = False - def __getattr__(self, key): + def __getattr__(self, key: str) -> MagicMock: return MagicMock() @@ -101,7 +104,7 @@ def unregister_single(con, name): del _modules[con.name][name] -def get(account, name): +def get(account: str, name: str) -> Any: try: return _modules[account][name] except KeyError: