summaryrefslogtreecommitdiff
path: root/poezio/ui
diff options
context:
space:
mode:
authorEmmanuel Gil Peyrot <linkmauve@linkmauve.fr>2020-12-12 18:44:37 +0100
committerEmmanuel Gil Peyrot <linkmauve@linkmauve.fr>2020-12-12 19:36:18 +0100
commit65b8046fe08a19df937068e5fe5ad15f9b0a785a (patch)
tree827e17a99d39c5db453d0fc0e9b46249292aa4e3 /poezio/ui
parent34ec9e3ee1384506b2e803bdfe94201a7b7ff4c3 (diff)
downloadpoezio-65b8046fe08a19df937068e5fe5ad15f9b0a785a.tar.gz
poezio-65b8046fe08a19df937068e5fe5ad15f9b0a785a.tar.bz2
poezio-65b8046fe08a19df937068e5fe5ad15f9b0a785a.tar.xz
poezio-65b8046fe08a19df937068e5fe5ad15f9b0a785a.zip
from __future__ import annotations
Now that our baseline is Python 3.7, we can rely on type annotations to be lazily evaluated.
Diffstat (limited to 'poezio/ui')
-rw-r--r--poezio/ui/render.py20
1 files changed, 11 insertions, 9 deletions
diff --git a/poezio/ui/render.py b/poezio/ui/render.py
index f37ea39e..13e493f1 100644
--- a/poezio/ui/render.py
+++ b/poezio/ui/render.py
@@ -1,3 +1,5 @@
+from __future__ import annotations
+
import curses
from datetime import (
@@ -52,7 +54,7 @@ LinePos = Tuple[int, int]
def generate_lines(lines: List[LinePos], msg: BaseMessage, default_color: str = '') -> List[Line]:
line_objects = []
- attrs = [] # type: List[str]
+ attrs: List[str] = []
prepend = default_color if default_color else ''
for line in lines:
saved = Line(
@@ -114,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)
@@ -122,7 +124,7 @@ def write_pre(msg: BaseMessage, win: 'Win', with_timestamps: bool, nick_size: in
@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
@@ -165,7 +167,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:
@@ -186,7 +188,7 @@ def write_pre_xmllog(msg: XMLLog, win: 'Win', with_timestamps: bool, nick_size:
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):
@@ -195,7 +197,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):
@@ -204,7 +206,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):
@@ -213,7 +215,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
@@ -231,7 +233,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
"""