From 65b8046fe08a19df937068e5fe5ad15f9b0a785a Mon Sep 17 00:00:00 2001 From: Emmanuel Gil Peyrot Date: Sat, 12 Dec 2020 18:44:37 +0100 Subject: from __future__ import annotations MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Now that our baseline is Python 3.7, we can rely on type annotations to be lazily evaluated. --- poezio/core/commands.py | 2 +- poezio/core/completions.py | 2 +- poezio/core/core.py | 2 +- poezio/core/tabs.py | 19 +++++++++---------- 4 files changed, 12 insertions(+), 13 deletions(-) (limited to 'poezio/core') diff --git a/poezio/core/commands.py b/poezio/core/commands.py index e926dba5..cd957002 100644 --- a/poezio/core/commands.py +++ b/poezio/core/commands.py @@ -335,7 +335,7 @@ class CommandCore: except InvalidJID: return (None, None) - set_nick = '' # type: Optional[str] + set_nick: Optional[str] = '' if len(jid_string) > 1 and jid_string.startswith('/'): set_nick = jid_string[1:] elif info.resource: diff --git a/poezio/core/completions.py b/poezio/core/completions.py index ada8d2b9..98ca9ba0 100644 --- a/poezio/core/completions.py +++ b/poezio/core/completions.py @@ -490,7 +490,7 @@ class CompletionCore: tabs.StaticConversationTab, tabs.DynamicConversationTab, ) - tabjid = [] # type: List[JID] + tabjid: List[JID] = [] if isinstance(current_tab, chattabs): tabjid = [current_tab.jid.bare] diff --git a/poezio/core/core.py b/poezio/core/core.py index 3a13d4c3..2151600f 100644 --- a/poezio/core/core.py +++ b/poezio/core/core.py @@ -1171,7 +1171,7 @@ class Core: """ # shortcut priority = tabs.STATE_PRIORITY - tab_refs = {} # type: Dict[str, List[tabs.Tab]] + tab_refs: Dict[str, List[tabs.Tab]] = {} # put all the active tabs in a dict of lists by state for tab in self.tabs.get_tabs(): if not tab: diff --git a/poezio/core/tabs.py b/poezio/core/tabs.py index 61bad6f2..a789100d 100644 --- a/poezio/core/tabs.py +++ b/poezio/core/tabs.py @@ -54,16 +54,15 @@ class Tabs: once. Otherwise, mayhem is expected. """ # cursor - self._current_index = 0 # type: int - self._current_tab = None # type: Optional[tabs.Tab] - - self._previous_tab = None # type: Optional[tabs.Tab] - self._tabs = [] # type: List[tabs.Tab] - self._tab_jids = dict() # type: Dict[JID, tabs.Tab] - self._tab_types = defaultdict( - list) # type: Dict[Type[tabs.Tab], List[tabs.Tab]] - self._tab_names = dict() # type: Dict[str, tabs.Tab] - self._events = events # type: EventHandler + self._current_index: int = 0 + self._current_tab: Optional[tabs.Tab] = None + + self._previous_tab: Optional[tabs.Tab] = None + self._tabs: List[tabs.Tab] = [] + self._tab_jids: Dict[JID, tabs.Tab] = dict() + self._tab_types: Dict[Type[tabs.Tab], List[tabs.Tab]] = defaultdict(list) + self._tab_names: Dict[str, tabs.Tab] = dict() + self._events: EventHandler = events def __len__(self): return len(self._tabs) -- cgit v1.2.3