diff options
-rw-r--r-- | poezio/tabs/basetabs.py | 15 | ||||
-rw-r--r-- | poezio/windows/base_wins.py | 10 |
2 files changed, 20 insertions, 5 deletions
diff --git a/poezio/tabs/basetabs.py b/poezio/tabs/basetabs.py index 0cae3c6a..2efc77a0 100644 --- a/poezio/tabs/basetabs.py +++ b/poezio/tabs/basetabs.py @@ -21,7 +21,15 @@ import time from math import ceil, log10 from datetime import datetime from xml.etree import cElementTree as ET -from typing import Any, Callable, Dict, List, Optional, Union +from typing import ( + Any, + Callable, + Dict, + List, + Optional, + Union, + TYPE_CHECKING, +) from poezio import mam, poopt, timed_events, xhtml, windows from poezio.core.structs import Command, Completion, Status @@ -35,6 +43,9 @@ from poezio.windows.funcs import truncate_nick from slixmpp import JID, InvalidJID, Message +if TYPE_CHECKING: + from _curses import _CursesWindow + log = logging.getLogger(__name__) # getters for tab colors (lambdas, so that they are dynamic) @@ -176,7 +187,7 @@ class Tab: self._state = 'normal' @staticmethod - def resize(scr): + def resize(scr: '_CursesWindow'): Tab.height, Tab.width = scr.getmaxyx() windows.base_wins.TAB_WIN = scr diff --git a/poezio/windows/base_wins.py b/poezio/windows/base_wins.py index 6dabd7b8..361ae338 100644 --- a/poezio/windows/base_wins.py +++ b/poezio/windows/base_wins.py @@ -7,7 +7,7 @@ the text window, the roster window, etc. A Tab (see the poezio.tabs module) is composed of multiple Windows """ -TAB_WIN = None +TAB_WIN = None # type: _CursesWindow import logging log = logging.getLogger(__name__) @@ -15,7 +15,8 @@ log = logging.getLogger(__name__) import curses import string -from typing import Optional, Tuple +from contextlib import contextmanager +from typing import Optional, Tuple, TYPE_CHECKING from poezio.theming import to_curses_attr, read_tuple @@ -24,6 +25,9 @@ FORMAT_CHAR = '\x19' # I guess. But maybe we can find better chars that are even less risky. format_chars = '\x0E\x0F\x10\x11\x12\x13\x14\x15\x16\x17\x18\x1A' +if TYPE_CHECKING: + from _curses import _CursesWindow + class DummyWin: def __getattribute__(self, name: str): @@ -40,7 +44,7 @@ class Win: __slots__ = ('_win', 'height', 'width', 'y', 'x') def __init__(self) -> None: - self._win = None + self._win = None # type: _CursesWindow self.height, self.width = 0, 0 def _resize(self, height: int, width: int, y: int, x: int) -> None: |