diff options
author | mathieui <mathieui@mathieui.net> | 2018-08-15 14:21:59 +0200 |
---|---|---|
committer | mathieui <mathieui@mathieui.net> | 2018-08-15 14:23:00 +0200 |
commit | 5ea82ac0af1cb855c9333796004c6a97da6b5ad4 (patch) | |
tree | f737e7e25012b76324ae03b591e19266a113a845 /poezio/core | |
parent | cccb1d97591966de1bab1b293294eefb17b90aac (diff) | |
download | poezio-5ea82ac0af1cb855c9333796004c6a97da6b5ad4.tar.gz poezio-5ea82ac0af1cb855c9333796004c6a97da6b5ad4.tar.bz2 poezio-5ea82ac0af1cb855c9333796004c6a97da6b5ad4.tar.xz poezio-5ea82ac0af1cb855c9333796004c6a97da6b5ad4.zip |
Fix mypy errors, add type annotations
Diffstat (limited to 'poezio/core')
-rw-r--r-- | poezio/core/core.py | 10 | ||||
-rw-r--r-- | poezio/core/tabs.py | 4 |
2 files changed, 7 insertions, 7 deletions
diff --git a/poezio/core/core.py b/poezio/core/core.py index 580e4c76..3f4e6b3b 100644 --- a/poezio/core/core.py +++ b/poezio/core/core.py @@ -1082,7 +1082,7 @@ class Core: return new_tab def open_private_window(self, room_name: str, user_nick: str, - focus=True) -> tabs.PrivateTab: + focus=True) -> Optional[tabs.PrivateTab]: """ Open a Private conversation in a MUC and focus if needed. """ @@ -1193,13 +1193,13 @@ class Core: if tab is not None: # display the message in private tab.update_status(status) - def close_tab(self, tab: tabs.Tab = None): + def close_tab(self, to_close: tabs.Tab = None): """ Close the given tab. If None, close the current one """ - was_current = tab is None - if tab is None: - tab = self.tabs.current_tab + was_current = to_close is None + tab = to_close or self.tabs.current_tab + if isinstance(tab, tabs.RosterInfoTab): return # The tab 0 should NEVER be closed tab.on_close() diff --git a/poezio/core/tabs.py b/poezio/core/tabs.py index b8c6d3a7..bcf6dd41 100644 --- a/poezio/core/tabs.py +++ b/poezio/core/tabs.py @@ -44,7 +44,7 @@ class Tabs: '_events', ] - def __init__(self, events: EventHandler): + def __init__(self, events: EventHandler) -> None: """ Initialize the Tab List. Even though the list is initially empty, all methods are only valid once append() has been called @@ -111,7 +111,7 @@ class Tabs: """Return the tab list""" return self._tabs - def by_name(self, name: str) -> tabs.Tab: + def by_name(self, name: str) -> Optional[tabs.Tab]: """Get a tab with a specific name""" return self._tab_names.get(name) |