summaryrefslogtreecommitdiff
path: root/slixmpp/stanza/presence.py
diff options
context:
space:
mode:
authormathieui <mathieui@mathieui.net>2021-07-15 10:01:03 +0200
committermathieui <mathieui@mathieui.net>2021-07-15 10:01:03 +0200
commit22fa8bc4d91d38a1176b09d03e0d41313b1adcaa (patch)
tree7344f9e7d72b913e9dfef29fe9b926364e7db587 /slixmpp/stanza/presence.py
parentb1411d8ed79792c6839f4aace13061256337e69b (diff)
parent5c54806578260adcb54b12b00a16cc8707a19263 (diff)
downloadslixmpp-22fa8bc4d91d38a1176b09d03e0d41313b1adcaa.tar.gz
slixmpp-22fa8bc4d91d38a1176b09d03e0d41313b1adcaa.tar.bz2
slixmpp-22fa8bc4d91d38a1176b09d03e0d41313b1adcaa.tar.xz
slixmpp-22fa8bc4d91d38a1176b09d03e0d41313b1adcaa.zip
Merge branch 'more-typing' into 'master'
Add more typing See merge request poezio/slixmpp!166
Diffstat (limited to 'slixmpp/stanza/presence.py')
-rw-r--r--slixmpp/stanza/presence.py17
1 files changed, 9 insertions, 8 deletions
diff --git a/slixmpp/stanza/presence.py b/slixmpp/stanza/presence.py
index 022e7133..d77ce1e4 100644
--- a/slixmpp/stanza/presence.py
+++ b/slixmpp/stanza/presence.py
@@ -1,4 +1,3 @@
-
# Slixmpp: The Slick XMPP Library
# Copyright (C) 2010 Nathanael C. Fritz
# This file is part of Slixmpp.
@@ -61,7 +60,7 @@ class Presence(RootStanza):
'subscribed', 'unsubscribe', 'unsubscribed'}
showtypes = {'dnd', 'chat', 'xa', 'away'}
- def __init__(self, *args, recv=False, **kwargs):
+ def __init__(self, *args, recv: bool = False, **kwargs):
"""
Initialize a new <presence /> stanza with an optional 'id' value.
@@ -69,10 +68,12 @@ class Presence(RootStanza):
"""
StanzaBase.__init__(self, *args, **kwargs)
if not recv and self['id'] == '':
- if self.stream is not None and self.stream.use_presence_ids:
- self['id'] = self.stream.new_id()
+ if self.stream:
+ use_ids = getattr(self.stream, 'use_presence_ids', None)
+ if use_ids:
+ self['id'] = self.stream.new_id()
- def set_show(self, show):
+ def set_show(self, show: str):
"""
Set the value of the <show> element.
@@ -84,7 +85,7 @@ class Presence(RootStanza):
self._set_sub_text('show', text=show)
return self
- def get_type(self):
+ def get_type(self) -> str:
"""
Return the value of the <presence> stanza's type attribute, or
the value of the <show> element if valid.
@@ -96,7 +97,7 @@ class Presence(RootStanza):
out = 'available'
return out
- def set_type(self, value):
+ def set_type(self, value: str):
"""
Set the type attribute's value, and the <show> element
if applicable.
@@ -119,7 +120,7 @@ class Presence(RootStanza):
self._del_attr('type')
self._del_sub('show')
- def set_priority(self, value):
+ def set_priority(self, value: int):
"""
Set the entity's priority value. Some server use priority to
determine message routing behavior.