summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormathieui <mathieui@mathieui.net>2020-05-22 18:46:17 +0200
committermathieui <mathieui@mathieui.net>2020-05-22 18:46:17 +0200
commitf5b407e9b2377051d3907182fec1981674ce0c04 (patch)
treeab615797b55db1a962dbb6d10a29db0c4160494e
parent936350471c07e12e0fd13da3eee6c8561053a8c4 (diff)
parenta876d4e2ee7f0d066d960a72c08ad6f7fe50001a (diff)
downloadpoezio-f5b407e9b2377051d3907182fec1981674ce0c04.tar.gz
poezio-f5b407e9b2377051d3907182fec1981674ce0c04.tar.bz2
poezio-f5b407e9b2377051d3907182fec1981674ce0c04.tar.xz
poezio-f5b407e9b2377051d3907182fec1981674ce0c04.zip
Merge branch 'muctab-presence-types' into 'master'
MucTab: add some typing to presence handlers See merge request poezio/poezio!104
-rw-r--r--poezio/tabs/muctab.py18
1 files changed, 9 insertions, 9 deletions
diff --git a/poezio/tabs/muctab.py b/poezio/tabs/muctab.py
index dc1a40d4..d16ac58a 100644
--- a/poezio/tabs/muctab.py
+++ b/poezio/tabs/muctab.py
@@ -18,9 +18,9 @@ import re
import functools
from copy import copy
from datetime import datetime
-from typing import Dict, Callable, List, Optional, Union, Set
+from typing import Dict, Callable, List, Optional, Tuple, Union, Set
-from slixmpp import InvalidJID, JID
+from slixmpp import InvalidJID, JID, Presence
from slixmpp.exceptions import IqError, IqTimeout
from poezio.tabs import ChatTab, Tab, SHOW_NAME
@@ -509,15 +509,15 @@ class MucTab(ChatTab):
self.core.tabs.current_tab.refresh_input()
self.core.doupdate()
- def handle_presence_unjoined(self, presence, deterministic, own=False):
+ def handle_presence_unjoined(self, presence: Presence, deterministic, own=False) -> None:
"""
Presence received while we are not in the room (before code=110)
"""
# If presence is coming from MUC barejid, ignore.
if not presence['from'].resource:
return None
- from_nick, _, affiliation, show, status, role, jid, typ = dissect_presence(
- presence)
+ dissected_presence = dissect_presence(presence)
+ from_nick, _, affiliation, show, status, role, jid, typ = dissected_presence
if typ == 'unavailable':
return
user_color = self.search_for_color(from_nick)
@@ -595,15 +595,15 @@ class MucTab(ChatTab):
),
typ=0)
- def handle_presence_joined(self, presence, status_codes):
+ def handle_presence_joined(self, presence: Presence, status_codes) -> None:
"""
Handle new presences when we are already in the room
"""
# If presence is coming from MUC barejid, ignore.
if not presence['from'].resource:
return None
- from_nick, from_room, affiliation, show, status, role, jid, typ = dissect_presence(
- presence)
+ dissected_presence = dissect_presence(presence)
+ from_nick, from_room, affiliation, show, status, role, jid, typ = dissected_presence
change_nick = '303' in status_codes
kick = '307' in status_codes and typ == 'unavailable'
ban = '301' in status_codes and typ == 'unavailable'
@@ -2195,7 +2195,7 @@ class PresenceError(Exception):
pass
-def dissect_presence(presence):
+def dissect_presence(presence: Presence) -> Tuple[str, str, str, str, str, str, JID, str]:
"""
Extract relevant information from a presence
"""