diff options
author | mathieui <mathieui@mathieui.net> | 2020-05-28 21:31:18 +0200 |
---|---|---|
committer | mathieui <mathieui@mathieui.net> | 2020-06-01 09:09:09 +0200 |
commit | c9e219c1405604f2ef81b3e446cc33a0492af42d (patch) | |
tree | 70a184a22724be16ce7a7ef930d07e9eda203ade /poezio/core/core.py | |
parent | 4fae01c09a286809f046c4347fa799f79a2cc129 (diff) | |
download | poezio-c9e219c1405604f2ef81b3e446cc33a0492af42d.tar.gz poezio-c9e219c1405604f2ef81b3e446cc33a0492af42d.tar.bz2 poezio-c9e219c1405604f2ef81b3e446cc33a0492af42d.tar.xz poezio-c9e219c1405604f2ef81b3e446cc33a0492af42d.zip |
mypy: Reduce errors on muctab.py by a lot
Diffstat (limited to 'poezio/core/core.py')
-rw-r--r-- | poezio/core/core.py | 29 |
1 files changed, 21 insertions, 8 deletions
diff --git a/poezio/core/core.py b/poezio/core/core.py index 3ad15719..3a13d4c3 100644 --- a/poezio/core/core.py +++ b/poezio/core/core.py @@ -15,7 +15,17 @@ import shutil import time import uuid from collections import defaultdict -from typing import Callable, Dict, List, Optional, Set, Tuple, Type +from typing import ( + cast, + Callable, + Dict, + List, + Optional, + Set, + Tuple, + Type, + TypeVar, +) from xml.etree import ElementTree as ET from functools import partial @@ -65,6 +75,7 @@ from poezio.ui.types import Message, InfoMessage log = logging.getLogger(__name__) +T = TypeVar('T', bound=tabs.Tab) class Core: """ @@ -99,8 +110,10 @@ class Core: # that are displayed in almost all tabs, in an # information window. self.information_buffer = TextBuffer() - self.information_win_size = config.get( - 'info_win_height', section='var') + self.information_win_size = cast( + int, + config.get('info_win_height', section='var'), + ) self.information_win = windows.TextWin(300) self.information_buffer.add_window(self.information_win) self.left_tab_win = None @@ -813,7 +826,7 @@ class Core: ####################### XMPP-related actions ################################## - def get_status(self) -> str: + def get_status(self) -> Status: """ Get the last status that was previously set """ @@ -1016,7 +1029,7 @@ class Core: ### Tab getters ### - def get_tabs(self, cls: Type[tabs.Tab] = None) -> List[tabs.Tab]: + def get_tabs(self, cls: Type[T] = None) -> List[T]: "Get all the tabs of a type" if cls is None: return self.tabs.get_tabs() @@ -1324,7 +1337,7 @@ class Core: if tab.name.startswith(room_name): tab.activate(reason=reason) - def on_user_changed_status_in_private(self, jid: JID, status: str) -> None: + def on_user_changed_status_in_private(self, jid: JID, status: Status) -> None: tab = self.tabs.by_name_and_class(jid, tabs.ChatTab) if tab is not None: # display the message in private tab.update_status(status) @@ -1652,7 +1665,7 @@ class Core: return else: scr = self.stdscr - tabs.Tab.resize(scr) + tabs.Tab.initial_resize(scr) self.resize_global_info_bar() self.resize_global_information_win() for tab in self.tabs: @@ -2105,7 +2118,7 @@ class Core: self.bookmarks.get_remote(self.xmpp, self.information, _join_remote_only) - def room_error(self, error, room_name): + def room_error(self, error: IqError, room_name: str) -> None: """ Display the error in the tab """ |