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


Commits:
6af78dc4 by lovetox at 2022-01-10T23:48:05+01:00
MainStack: Add type annotations

- - - - -


3 changed files:

- gajim/gtk/app_page.py
- gajim/gtk/main_stack.py
- pyrightconfig.json


Changes:

=====================================
gajim/gtk/app_page.py
=====================================
@@ -18,6 +18,7 @@
 from gi.repository import Gtk
 
 from gajim.common import app
+from gajim.common.events import ApplicationEvent
 from gajim.common.helpers import open_uri
 from gajim.common.i18n import _
 
@@ -77,7 +78,7 @@ def remove_app_message(self) -> None:
         self._unread_count -= 1
         self.emit('unread-count-changed', self._unread_count)
 
-    def process_event(self, event):
+    def process_event(self, event: ApplicationEvent) -> None:
         pass
 
 


=====================================
gajim/gtk/main_stack.py
=====================================
@@ -12,19 +12,27 @@
 # 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 Union
+from typing import cast
+
 from nbxmpp.protocol import JID
 
 from gi.repository import Gtk
 
 from gajim.common import app
 from gajim.common.events import ApplicationEvent
-from gajim.gtk.chat_list import ChatList
 
 from .app_page import AppPage
+from .chat_list import ChatList
 from .chat_page import ChatPage
 from .account_page import AccountPage
 
 
+PageT = Union[ChatPage, AccountPage, AppPage]
+
+
 class MainStack(Gtk.Stack):
     def __init__(self) -> None:
         Gtk.Stack.__init__(self)
@@ -82,7 +90,8 @@ def get_chat_page(self) -> ChatPage:
 
     def process_event(self, event: ApplicationEvent) -> None:
         empty_box = self.get_child_by_name('empty')
-        for page in self.get_children():
+        pages = cast(list[PageT], self.get_children())
+        for page in pages:
             if page is empty_box:
                 continue
             page.process_event(event)


=====================================
pyrightconfig.json
=====================================
@@ -36,6 +36,7 @@
         "gajim/gtk/conversation/rows/scroll_hint.py",
         "gajim/gtk/conversation/rows/widgets.py",
         "gajim/gtk/conversation/scrolled.py",
+        "gajim/gtk/main_stack.py",
         "gajim/gtk/notification.py",
         "gajim/gtk/side_bar_switcher.py",
         "gajim/gtk/status_icon.py",



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

-- 
View it on GitLab: 
https://dev.gajim.org/gajim/gajim/-/commit/6af78dc488474662b51640f38b22ae08c6a8ea05
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