From 7d4172808fb1ecee42da29211aa3b48b986902b3 Mon Sep 17 00:00:00 2001 From: mathieui Date: Sat, 3 Jul 2021 11:09:41 +0200 Subject: stanza: add typing --- slixmpp/stanza/presence.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'slixmpp/stanza/presence.py') diff --git a/slixmpp/stanza/presence.py b/slixmpp/stanza/presence.py index 022e7133..1a3b7c78 100644 --- a/slixmpp/stanza/presence.py +++ b/slixmpp/stanza/presence.py @@ -61,7 +61,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 stanza with an optional 'id' value. @@ -72,7 +72,7 @@ class Presence(RootStanza): if self.stream is not None and self.stream.use_presence_ids: self['id'] = self.stream.new_id() - def set_show(self, show): + def set_show(self, show: str): """ Set the value of the element. @@ -84,7 +84,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 stanza's type attribute, or the value of the element if valid. @@ -96,7 +96,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 element if applicable. @@ -119,7 +119,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. -- cgit v1.2.3 From af958fd1fe46d4a3f523ee3f4f103f15430b5fc2 Mon Sep 17 00:00:00 2001 From: mathieui Date: Mon, 5 Jul 2021 22:29:37 +0200 Subject: stanza: fix a bunch of type errors --- slixmpp/stanza/presence.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'slixmpp/stanza/presence.py') diff --git a/slixmpp/stanza/presence.py b/slixmpp/stanza/presence.py index 1a3b7c78..a0742a95 100644 --- a/slixmpp/stanza/presence.py +++ b/slixmpp/stanza/presence.py @@ -5,6 +5,7 @@ # See the file LICENSE for copying permission. from slixmpp.stanza.rootstanza import RootStanza from slixmpp.xmlstream import StanzaBase +from slixmpp.basexmpp import BaseXMPP class Presence(RootStanza): @@ -69,7 +70,7 @@ 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: + if isinstance(self.stream, BaseXMPP) and self.stream.use_presence_ids: self['id'] = self.stream.new_id() def set_show(self, show: str): -- cgit v1.2.3 From 5c54806578260adcb54b12b00a16cc8707a19263 Mon Sep 17 00:00:00 2001 From: mathieui Date: Mon, 5 Jul 2021 23:05:57 +0200 Subject: stanza: fix circular imports ew --- slixmpp/stanza/presence.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'slixmpp/stanza/presence.py') diff --git a/slixmpp/stanza/presence.py b/slixmpp/stanza/presence.py index a0742a95..d77ce1e4 100644 --- a/slixmpp/stanza/presence.py +++ b/slixmpp/stanza/presence.py @@ -1,11 +1,9 @@ - # Slixmpp: The Slick XMPP Library # Copyright (C) 2010 Nathanael C. Fritz # This file is part of Slixmpp. # See the file LICENSE for copying permission. from slixmpp.stanza.rootstanza import RootStanza from slixmpp.xmlstream import StanzaBase -from slixmpp.basexmpp import BaseXMPP class Presence(RootStanza): @@ -70,8 +68,10 @@ class Presence(RootStanza): """ StanzaBase.__init__(self, *args, **kwargs) if not recv and self['id'] == '': - if isinstance(self.stream, BaseXMPP) 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: str): """ -- cgit v1.2.3