summaryrefslogtreecommitdiff
path: root/poezio/ui
diff options
context:
space:
mode:
authormathieui <mathieui@mathieui.net>2019-10-27 14:46:01 +0100
committermathieui <mathieui@mathieui.net>2020-05-09 19:46:17 +0200
commit3d13d1d99494a5795ca516939d49c2ad2397e1a9 (patch)
tree7e61f21d1a212d81f38e2533599430ca5287bcd4 /poezio/ui
parentcad5d0d88a29195f287fbaea0cbfeac4463422d3 (diff)
downloadpoezio-3d13d1d99494a5795ca516939d49c2ad2397e1a9.tar.gz
poezio-3d13d1d99494a5795ca516939d49c2ad2397e1a9.tar.bz2
poezio-3d13d1d99494a5795ca516939d49c2ad2397e1a9.tar.xz
poezio-3d13d1d99494a5795ca516939d49c2ad2397e1a9.zip
Typing improvements
Diffstat (limited to 'poezio/ui')
-rw-r--r--poezio/ui/render.py26
1 files changed, 16 insertions, 10 deletions
diff --git a/poezio/ui/render.py b/poezio/ui/render.py
index 3f94ecd8..b8368312 100644
--- a/poezio/ui/render.py
+++ b/poezio/ui/render.py
@@ -3,14 +3,17 @@ import curses
from datetime import datetime
from functools import singledispatch
-from typing import List, Tuple
from math import ceil, log10
+from typing import (
+ List,
+ Tuple,
+ TYPE_CHECKING,
+)
from poezio import poopt
from poezio.theming import (
get_theme,
)
-from poezio.windows import Win
from poezio.ui.consts import (
FORMAT_CHAR,
LONG_FORMAT,
@@ -27,6 +30,9 @@ from poezio.ui.types import (
XMLLog,
)
+if TYPE_CHECKING:
+ from poezio.windows import Win
+
# msg is a reference to the corresponding Message object. text_start and
# text_end are the position delimiting the text in this line.
class Line:
@@ -110,7 +116,7 @@ def build_xmllog(msg: XMLLog, width: int, timestamp: bool, nick_size: int = 10)
@singledispatch
-def write_pre(msg: BaseMessage, win: Win, with_timestamps: bool, nick_size: int) -> int:
+def write_pre(msg: BaseMessage, win: 'Win', with_timestamps: bool, nick_size: int) -> int:
"""Write the part before text (only the timestamp)"""
if with_timestamps:
return PreMessageHelpers.write_time(win, False, msg.time)
@@ -118,7 +124,7 @@ def write_pre(msg: BaseMessage, win: Win, with_timestamps: bool, nick_size: int)
@write_pre.register(Message)
-def write_pre_message(msg: Message, win: Win, with_timestamps: bool, nick_size: int) -> int:
+def write_pre_message(msg: Message, win: 'Win', with_timestamps: bool, nick_size: int) -> int:
"""Write the part before the body:
- timestamp (short or long)
- ack/nack
@@ -162,7 +168,7 @@ def write_pre_message(msg: Message, win: Win, with_timestamps: bool, nick_size:
@write_pre.register(XMLLog)
-def write_pre_xmllog(msg: XMLLog, win: Win, with_timestamps: bool, nick_size: int) -> int:
+def write_pre_xmllog(msg: XMLLog, win: 'Win', with_timestamps: bool, nick_size: int) -> int:
"""Write the part before the stanza (timestamp + IN/OUT)"""
offset = 0
if with_timestamps:
@@ -183,7 +189,7 @@ def write_pre_xmllog(msg: XMLLog, win: Win, with_timestamps: bool, nick_size: in
class PreMessageHelpers:
@staticmethod
- def write_revisions(buffer: Win, msg: Message) -> int:
+ def write_revisions(buffer: 'Win', msg: Message) -> int:
if msg.revisions:
color = get_theme().COLOR_REVISIONS_MESSAGE
with buffer.colored_text(color=color):
@@ -192,7 +198,7 @@ class PreMessageHelpers:
return 0
@staticmethod
- def write_ack(buffer: Win) -> int:
+ def write_ack(buffer: 'Win') -> int:
theme = get_theme()
color = theme.COLOR_CHAR_ACK
with buffer.colored_text(color=color):
@@ -201,7 +207,7 @@ class PreMessageHelpers:
return poopt.wcswidth(theme.CHAR_ACK_RECEIVED) + 1
@staticmethod
- def write_nack(buffer: Win) -> int:
+ def write_nack(buffer: 'Win') -> int:
theme = get_theme()
color = theme.COLOR_CHAR_NACK
with buffer.colored_text(color=color):
@@ -210,7 +216,7 @@ class PreMessageHelpers:
return poopt.wcswidth(theme.CHAR_NACK) + 1
@staticmethod
- def write_nickname(buffer: Win, nickname: str, color, highlight=False) -> None:
+ def write_nickname(buffer: 'Win', nickname: str, color, highlight=False) -> None:
"""
Write the nickname, using the user's color
and return the number of written characters
@@ -228,7 +234,7 @@ class PreMessageHelpers:
buffer.addstr(nickname)
@staticmethod
- def write_time(buffer: Win, history: bool, time: datetime) -> int:
+ def write_time(buffer: 'Win', history: bool, time: datetime) -> int:
"""
Write the date on the yth line of the window
"""