summaryrefslogtreecommitdiff
path: root/poezio/text_buffer.py
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/text_buffer.py
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/text_buffer.py')
-rw-r--r--poezio/text_buffer.py16
1 files changed, 9 insertions, 7 deletions
diff --git a/poezio/text_buffer.py b/poezio/text_buffer.py
index 6ef8e3d4..89bae3a2 100644
--- a/poezio/text_buffer.py
+++ b/poezio/text_buffer.py
@@ -8,6 +8,8 @@ Each text buffer can be linked to multiple windows, that will be rendered
independently by their TextWins.
"""
+from __future__ import annotations
+
import logging
log = logging.getLogger(__name__)
@@ -62,23 +64,23 @@ class TextBuffer:
if messages_nb_limit is None:
messages_nb_limit = cast(int, config.get('max_messages_in_memory'))
- self._messages_nb_limit = messages_nb_limit # type: int
+ self._messages_nb_limit: int = messages_nb_limit
# Message objects
- self.messages = [] # type: List[BaseMessage]
+ self.messages: List[BaseMessage] = []
# COMPAT: Correction id -> Original message id.
- self.correction_ids = {} # type: Dict[str, str]
+ self.correction_ids: Dict[str, str] = {}
# we keep track of one or more windows
# so we can pass the new messages to them, as they are added, so
# they (the windows) can build the lines from the new message
- self._windows = [] # type: List[TextWin]
+ self._windows: List[TextWin] = []
def add_window(self, win) -> None:
self._windows.append(win)
def find_last_gap_muc(self) -> Optional[HistoryGap]:
"""Find the last known history gap contained in buffer"""
- leave = None # type:Optional[Tuple[int, BaseMessage]]
- join = None # type:Optional[Tuple[int, BaseMessage]]
+ leave: Optional[Tuple[int, BaseMessage]] = None
+ join: Optional[Tuple[int, BaseMessage]] = None
for i, item in enumerate(reversed(self.messages)):
if isinstance(item, MucOwnLeaveMessage):
leave = (len(self.messages) - i - 1, item)
@@ -250,7 +252,7 @@ class TextBuffer:
new_id: str,
highlight: bool = False,
time: Optional[datetime] = None,
- user: Optional['User'] = None,
+ user: Optional[User] = None,
jid: Optional[str] = None) -> Message:
"""
Correct a message in a text buffer.