diff options
author | lovetox <philipp@hoerist.com> | 2021-12-28 19:29:55 +0300 |
---|---|---|
committer | lovetox <philipp@hoerist.com> | 2021-12-28 19:29:55 +0300 |
commit | f6015828ab98b059f150cf42877d06bd625f5a34 (patch) | |
tree | da607578d516ba2e6f550ed260d2d32c7bea6f42 | |
parent | 34ab976517298b0399a3f58fb1a9eef312da0a24 (diff) |
Helpers: Add type annotations
-rw-r--r-- | gajim/common/helpers.py | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/gajim/common/helpers.py b/gajim/common/helpers.py index 80e56e9dd..83c42a53b 100644 --- a/gajim/common/helpers.py +++ b/gajim/common/helpers.py @@ -827,17 +827,16 @@ def ignore_contact(account: str, jid: JID) -> bool: class AdditionalDataDict(collections.UserDict): - def __init__(self, initialdata=None): - collections.UserDict.__init__(self, initialdata) + data: dict[str, Any] @staticmethod - def _get_path_childs(full_path): + def _get_path_childs(full_path: str) -> list[str]: path_childs = [full_path] if ':' in full_path: path_childs = full_path.split(':') return path_childs - def set_value(self, full_path, key, value): + def set_value(self, full_path: str, key: str, value: str) -> None: path_childs = self._get_path_childs(full_path) _dict = self.data for path in path_childs: @@ -848,7 +847,11 @@ class AdditionalDataDict(collections.UserDict): _dict = _dict[path] _dict[key] = value - def get_value(self, full_path, key, default=None): + def get_value(self, + full_path: str, + key: str, + default: Optional[str] = None) -> Optional[str]: + path_childs = self._get_path_childs(full_path) _dict = self.data for path in path_childs: @@ -861,7 +864,7 @@ class AdditionalDataDict(collections.UserDict): except KeyError: return default - def remove_value(self, full_path, key): + def remove_value(self, full_path: str, key: str) -> None: path_childs = self._get_path_childs(full_path) _dict = self.data for path in path_childs: @@ -874,7 +877,7 @@ class AdditionalDataDict(collections.UserDict): except KeyError: return - def copy(self): + def copy(self) -> AdditionalDataDict: return copy.deepcopy(self) @@ -1054,7 +1057,7 @@ def open_uri(uri: Union[URI, str], account: Optional[str] = None) -> None: @catch_exceptions -def open_file(path): +def open_file(path: str) -> None: if os.name == 'nt': os.startfile(path) else: @@ -1329,8 +1332,9 @@ def convert_gio_to_openssl_cert(cert): return cert -def get_custom_host(account: str - ) -> Optional[Tuple[str, ConnectionProtocol, str]]: +def get_custom_host(account: str) -> Optional[Tuple[str, + ConnectionProtocol, + ConnectionType]]: if not app.settings.get_account_setting(account, 'use_custom_host'): return None host = app.settings.get_account_setting(account, 'custom_host') |