diff options
Diffstat (limited to 'poezio/windows')
-rw-r--r-- | poezio/windows/base_wins.py | 6 | ||||
-rw-r--r-- | poezio/windows/bookmark_forms.py | 2 | ||||
-rw-r--r-- | poezio/windows/image.py | 4 | ||||
-rw-r--r-- | poezio/windows/info_wins.py | 8 | ||||
-rw-r--r-- | poezio/windows/input_placeholders.py | 2 | ||||
-rw-r--r-- | poezio/windows/inputs.py | 16 | ||||
-rw-r--r-- | poezio/windows/list.py | 8 | ||||
-rw-r--r-- | poezio/windows/misc.py | 2 | ||||
-rw-r--r-- | poezio/windows/muc.py | 2 | ||||
-rw-r--r-- | poezio/windows/roster_win.py | 4 | ||||
-rw-r--r-- | poezio/windows/text_win.py | 10 |
11 files changed, 34 insertions, 30 deletions
diff --git a/poezio/windows/base_wins.py b/poezio/windows/base_wins.py index f371c106..1347553a 100644 --- a/poezio/windows/base_wins.py +++ b/poezio/windows/base_wins.py @@ -7,7 +7,9 @@ the text window, the roster window, etc. A Tab (see the poezio.tabs module) is composed of multiple Windows """ -TAB_WIN = None # type: _CursesWindow +from __future__ import annotations + +TAB_WIN: _CursesWindow = None import logging log = logging.getLogger(__name__) @@ -41,7 +43,7 @@ class Win: __slots__ = ('_win', 'height', 'width', 'y', 'x') def __init__(self) -> None: - self._win = None # type: _CursesWindow + self._win: _CursesWindow = None self.height, self.width = 0, 0 def _resize(self, height: int, width: int, y: int, x: int) -> None: diff --git a/poezio/windows/bookmark_forms.py b/poezio/windows/bookmark_forms.py index d538e6a2..f1e737fd 100644 --- a/poezio/windows/bookmark_forms.py +++ b/poezio/windows/bookmark_forms.py @@ -161,7 +161,7 @@ class BookmarksWin(Win): self._current_input = 0 self.current_horizontal_input = 0 self._bookmarks = list(bookmarks) - self.lines = [] # type: List[Tuple[BookmarkNameInput, BookmarkJIDInput, BookmarkPasswordInput, BookmarkAutojoinWin, BookmarkMethodInput]] + self.lines: List[Tuple[BookmarkNameInput, BookmarkJIDInput, BookmarkPasswordInput, BookmarkAutojoinWin, BookmarkMethodInput]] = [] for bookmark in sorted(self._bookmarks, key=lambda x: str(x.jid)): self.lines.append((BookmarkNameInput(bookmark), BookmarkJIDInput(bookmark), diff --git a/poezio/windows/image.py b/poezio/windows/image.py index ebecb5ad..79ecf7d9 100644 --- a/poezio/windows/image.py +++ b/poezio/windows/image.py @@ -69,10 +69,10 @@ class ImageWin(Win): __slots__ = ('_image', '_display_avatar') def __init__(self) -> None: - self._image = None # type: Optional[Image.Image] + self._image: Optional[Image.Image] = None Win.__init__(self) if config.get('image_use_half_blocks'): - self._display_avatar = self._display_avatar_half_blocks # type: Callable[[int, int], None] + self._display_avatar: Callable[[int, int], None] = self._display_avatar_half_blocks else: self._display_avatar = self._display_avatar_full_blocks diff --git a/poezio/windows/info_wins.py b/poezio/windows/info_wins.py index c3975c8c..cd775e33 100644 --- a/poezio/windows/info_wins.py +++ b/poezio/windows/info_wins.py @@ -3,6 +3,8 @@ Module defining all the "info wins", ie the bar which is on top of the info buffer in normal tabs """ +from __future__ import annotations + from typing import Optional, Dict, TYPE_CHECKING, Any import logging @@ -272,9 +274,9 @@ class MucInfoWin(InfoWin): def refresh( self, - room: 'MucTab', - window: Optional['TextWin'] = None, - user: Optional['User'] = None, + room: MucTab, + window: Optional[TextWin] = None, + user: Optional[User] = None, information: Optional[Dict[str, Any]] = None ) -> None: log.debug('Refresh: %s', self.__class__.__name__) diff --git a/poezio/windows/input_placeholders.py b/poezio/windows/input_placeholders.py index 4d414636..3ec57583 100644 --- a/poezio/windows/input_placeholders.py +++ b/poezio/windows/input_placeholders.py @@ -23,7 +23,7 @@ class HelpText(Win): def __init__(self, text: str = '') -> None: Win.__init__(self) - self.txt = text # type: str + self.txt: str = text def refresh(self, txt: Optional[str] = None) -> None: log.debug('Refresh: %s', self.__class__.__name__) diff --git a/poezio/windows/inputs.py b/poezio/windows/inputs.py index 5cca8803..b3601913 100644 --- a/poezio/windows/inputs.py +++ b/poezio/windows/inputs.py @@ -41,7 +41,7 @@ class Input(Win): # it easy cut and paste text between various input def __init__(self) -> None: - self.key_func = { + self.key_func: Dict[str, Callable] = { "KEY_LEFT": self.key_left, "KEY_RIGHT": self.key_right, "KEY_END": self.key_end, @@ -66,7 +66,7 @@ class Input(Win): '^?': self.key_backspace, "M-^?": self.delete_word, # '^J': self.add_line_break, - } # type: Dict[str, Callable] + } Win.__init__(self) self.text = '' self.pos = 0 # The position of the “cursor” in the text @@ -76,8 +76,8 @@ class Input(Win): # screen self.on_input = DEFAULT_ON_INPUT # callback called on any key pressed self.color = None # use this color on addstr - self.last_completion = None # type: Optional[str] - self.hit_list = [] # type: List[str] + self.last_completion: Optional[str] = None + self.hit_list: List[str] = [] def on_delete(self) -> None: """ @@ -592,7 +592,7 @@ class HistoryInput(Input): """ __slots__ = ('help_message', 'histo_pos', 'current_completed', 'search') - history = [] # type: List[str] + history: List[str] = [] def __init__(self) -> None: Input.__init__(self) @@ -603,7 +603,7 @@ class HistoryInput(Input): self.search = False if config.get('separate_history'): # pylint: disable=assigning-non-slot - self.history = [] # type: List[str] + self.history: List[str] = [] def toggle_search(self) -> None: if self.help_message: @@ -680,7 +680,7 @@ class MessageInput(HistoryInput): Also letting the user enter colors or other text markups """ # The history is common to all MessageInput - history = [] # type: List[str] + history: List[str] = [] def __init__(self) -> None: HistoryInput.__init__(self) @@ -726,7 +726,7 @@ class CommandInput(HistoryInput): HelpMessage when a command is started The on_input callback """ - history = [] # type: List[str] + history: List[str] = [] def __init__(self, help_message: str, on_abort, on_success, on_input=None) -> None: HistoryInput.__init__(self) diff --git a/poezio/windows/list.py b/poezio/windows/list.py index c427a79e..1c5d834f 100644 --- a/poezio/windows/list.py +++ b/poezio/windows/list.py @@ -24,10 +24,10 @@ class ListWin(Win): def __init__(self, columns: Dict[str, int], with_headers: bool = True) -> None: Win.__init__(self) - self._columns = columns # type: Dict[str, int] - self._columns_sizes = {} # type: Dict[str, int] + self._columns: Dict[str, int] = columns + self._columns_sizes: Dict[str, int] = {} self.sorted_by = (None, None) # for example: ('name', '↑') - self.lines = [] # type: List[str] + self.lines: List[str] = [] self._selected_row = 0 self._starting_pos = 0 # The column number from which we start the refresh @@ -173,7 +173,7 @@ class ColumnHeaderWin(Win): def __init__(self, columns: List[str]) -> None: Win.__init__(self) self._columns = columns - self._columns_sizes = {} # type: Dict[str, int] + self._columns_sizes: Dict[str, int] = {} self._column_sel = '' self._column_order = '' self._column_order_asc = False diff --git a/poezio/windows/misc.py b/poezio/windows/misc.py index 6c04b814..8739db0c 100644 --- a/poezio/windows/misc.py +++ b/poezio/windows/misc.py @@ -37,7 +37,7 @@ class SimpleTextWin(Win): def __init__(self, text) -> None: Win.__init__(self) self._text = text - self.built_lines = [] # type: List[str] + self.built_lines: List[str] = [] def rebuild_text(self) -> None: """ diff --git a/poezio/windows/muc.py b/poezio/windows/muc.py index 951940e1..05fe683e 100644 --- a/poezio/windows/muc.py +++ b/poezio/windows/muc.py @@ -33,7 +33,7 @@ class UserList(Win): def __init__(self) -> None: Win.__init__(self) self.pos = 0 - self.cache = [] # type: List[CachedUser] + self.cache: List[CachedUser] = [] def scroll_up(self) -> bool: self.pos += self.height - 1 diff --git a/poezio/windows/roster_win.py b/poezio/windows/roster_win.py index 2efdd324..c4a1c30b 100644 --- a/poezio/windows/roster_win.py +++ b/poezio/windows/roster_win.py @@ -26,8 +26,8 @@ class RosterWin(Win): Win.__init__(self) self.pos = 0 # cursor position in the contact list self.start_pos = 1 # position of the start of the display - self.selected_row = None # type: Optional[Row] - self.roster_cache = [] # type: List[Row] + self.selected_row: Optional[Row] = None + self.roster_cache: List[Row] = [] @property def roster_len(self) -> int: diff --git a/poezio/windows/text_win.py b/poezio/windows/text_win.py index 2cb75271..ac60dee7 100644 --- a/poezio/windows/text_win.py +++ b/poezio/windows/text_win.py @@ -30,17 +30,17 @@ class TextWin(Win): Win.__init__(self) if lines_nb_limit is None: lines_nb_limit = config.get('max_lines_in_memory') - self.lines_nb_limit = lines_nb_limit # type: int + self.lines_nb_limit: int = lines_nb_limit self.pos = 0 # Each new message is built and kept here. # on resize, we rebuild all the messages - self.built_lines = [] # type: List[Union[None, Line]] + self.built_lines: List[Union[None, Line]] = [] self.lock = False - self.lock_buffer = [] # type: List[Union[None, Line]] - self.separator_after = None # type: Optional[Line] + self.lock_buffer: List[Union[None, Line]] = [] + self.separator_after: Optional[Line] = None # the Lines of the highlights in that buffer - self.highlights = [] # type: List[Line] + self.highlights: List[Line] = [] # the current HL position in that list NaN means that we’re not on # an hl. -1 is a valid position (it's before the first hl of the # list. i.e the separator, in the case where there’s no hl before |