Philipp Hörist pushed to branch master at gajim / gajim


Commits:
f891fdc2 by lovetox at 2021-11-29T20:01:01+01:00
Add annotations

- - - - -


4 changed files:

- gajim/common/app.py
- gajim/common/types.py
- gajim/gui/__init__.py
- gajim/history_manager.py


Changes:

=====================================
gajim/common/app.py
=====================================
@@ -24,6 +24,8 @@
 # You should have received a copy of the GNU General Public License
 # along with Gajim. If not, see <http://www.gnu.org/licenses/>.
 
+from __future__ import annotations
+
 from typing import Any  # pylint: disable=unused-import
 from typing import Dict  # pylint: disable=unused-import
 from typing import List  # pylint: disable=unused-import
@@ -53,6 +55,8 @@
 from gajim.common.types import ConnectionT  # pylint: disable=unused-import
 from gajim.common.types import LegacyContactsAPIT  # pylint: 
disable=unused-import
 from gajim.common.types import SettingsT  # pylint: disable=unused-import
+from gajim.common.types import CSSConfigT  # pylint: disable=unused-import
+
 
 interface = cast(InterfaceT, None)
 thread_interface = lambda *args: None # Interface to run a thread and then a 
callback
@@ -76,7 +80,7 @@ def __init__(self):
 
 storage = Storage()
 
-css_config = None
+css_config = cast(CSSConfigT, None)
 
 transport_type = {}  # type: Dict[str, str]
 


=====================================
gajim/common/types.py
=====================================
@@ -41,6 +41,7 @@
 
     from gajim.gui_interface import Interface
     from gajim.common.settings import Settings
+    from gajim.gtk.css_config import CSSConfig
 
 
 NetworkEventsControllerT = Union['NetworkEventsController']
@@ -50,6 +51,7 @@
 ContactsT = Union['Contact', 'GC_Contact']
 ContactT = Union['Contact']
 LegacyContactsAPIT = Union['LegacyContactsAPI']
+CSSConfigT = Union['CSSConfig']
 
 # PEP
 PEPNotifyCallback = Callable[[nbxmpp.JID, nbxmpp.Node], None]


=====================================
gajim/gui/__init__.py
=====================================
@@ -1,24 +1,36 @@
 
+from __future__ import annotations
+
+from typing import Union
+from typing import Sequence
+from typing import Optional
+
+import types
 import sys
 from importlib.abc import MetaPathFinder
 from importlib.util import spec_from_file_location
+from importlib.machinery import ModuleSpec
 from pathlib import Path
 
 
 class GUIFinder(MetaPathFinder):
 
-    def __init__(self, name, fallback=None):
+    def __init__(self, name: str, fallback: Optional[str] = None) -> None:
         self._path = Path(__file__).parent.parent / name
 
         self._fallback_path = None
         if fallback is not None:
             self._fallback_path = Path(__file__).parent.parent / fallback
 
-    def find_spec(self, fullname, _path, _target=None):
+    def find_spec(self,
+                  fullname: str,
+                  path: Optional[Sequence[Union[bytes, str]]],
+                  target: Optional[types.ModuleType] = None) -> 
Optional[ModuleSpec]:
+
         if not fullname.startswith('gajim.gui'):
             return None
 
-        _namespace, module_name = fullname.rsplit('.', 1)
+        _, module_name = fullname.rsplit('.', 1)
         module_path = self._find_module(module_name)
         if module_path is None:
             return None
@@ -27,7 +39,7 @@ def find_spec(self, fullname, _path, _target=None):
 
         return spec
 
-    def _find_module(self, module_name):
+    def _find_module(self, module_name: str) -> Optional[Path]:
         module_path = self._path / f'{module_name}.py'
         if module_path.exists():
             return module_path
@@ -50,5 +62,5 @@ def _find_module(self, module_name):
         return None
 
 
-def init(name, fallback=None):
+def init(name: str, fallback: Optional[str] = None) -> None:
     sys.meta_path.append(GUIFinder(name, fallback=fallback))


=====================================
gajim/history_manager.py
=====================================
@@ -70,7 +70,7 @@ def is_standalone() -> bool:
 
 def init_gtk() -> None:
     gajim.gui.init('gtk')
-    from gajim.gui import exception
+    from gajim.gtk import exception
     exception.init()
 
 



View it on GitLab: 
https://dev.gajim.org/gajim/gajim/-/commit/f891fdc2125c8c0b11c2656947ed621bf211bf3d

-- 
View it on GitLab: 
https://dev.gajim.org/gajim/gajim/-/commit/f891fdc2125c8c0b11c2656947ed621bf211bf3d
You're receiving this email because of your account on dev.gajim.org.


_______________________________________________
Commits mailing list
[email protected]
https://lists.gajim.org/cgi-bin/listinfo/commits

Reply via email to