diff --git a/slixmpp/stanza/error.py b/slixmpp/stanza/error.py
index 54ace5a8..83742a5c 100644
--- a/slixmpp/stanza/error.py
+++ b/slixmpp/stanza/error.py
@@ -1,8 +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 __future__ import annotations
+from typing import Optional
from slixmpp.xmlstream import ElementBase, ET
@@ -62,10 +63,10 @@ class Error(ElementBase):
'remote-server-timeout', 'resource-constraint',
'service-unavailable', 'subscription-required',
'undefined-condition', 'unexpected-request'}
- condition_ns = 'urn:ietf:params:xml:ns:xmpp-stanzas'
+ condition_ns: str = 'urn:ietf:params:xml:ns:xmpp-stanzas'
types = {'cancel', 'continue', 'modify', 'auth', 'wait'}
- def setup(self, xml=None):
+ def setup(self, xml: Optional[ET.Element]=None):
"""
Populate the stanza object using an optional XML object.
@@ -84,7 +85,7 @@ class Error(ElementBase):
if self.parent is not None:
self.parent()['type'] = 'error'
- def get_condition(self):
+ def get_condition(self) -> str:
"""Return the condition element's name."""
for child in self.xml:
if "{%s}" % self.condition_ns in child.tag:
@@ -93,7 +94,7 @@ class Error(ElementBase):
return cond
return ''
- def set_condition(self, value):
+ def set_condition(self, value: str) -> Error:
"""
Set the tag name of the condition element.
@@ -105,7 +106,7 @@ class Error(ElementBase):
self.xml.append(ET.Element("{%s}%s" % (self.condition_ns, value)))
return self
- def del_condition(self):
+ def del_condition(self) -> None:
"""Remove the condition element."""
for child in self.xml:
if "{%s}" % self.condition_ns in child.tag:
@@ -139,14 +140,14 @@ class Error(ElementBase):
def get_redirect(self):
return self._get_sub_text('{%s}redirect' % self.condition_ns, '')
- def set_gone(self, value):
+ def set_gone(self, value: str):
if value:
del self['condition']
return self._set_sub_text('{%s}gone' % self.condition_ns, value)
elif self['condition'] == 'gone':
del self['condition']
- def set_redirect(self, value):
+ def set_redirect(self, value: str):
if value:
del self['condition']
ns = self.condition_ns
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.
diff --git a/slixmpp/stanza/stream_error.py b/slixmpp/stanza/stream_error.py
index 0e728c8e..d2036a3c 100644
--- a/slixmpp/stanza/stream_error.py
+++ b/slixmpp/stanza/stream_error.py
@@ -62,13 +62,13 @@ class StreamError(Error, StanzaBase):
'system-shutdown', 'undefined-condition', 'unsupported-encoding',
'unsupported-feature', 'unsupported-stanza-type',
'unsupported-version'}
- condition_ns = 'urn:ietf:params:xml:ns:xmpp-streams'
+ condition_ns: str = 'urn:ietf:params:xml:ns:xmpp-streams'
- def get_see_other_host(self):
+ def get_see_other_host(self) -> str:
ns = self.condition_ns
return self._get_sub_text('{%s}see-other-host' % ns, '')
- def set_see_other_host(self, value):
+ def set_see_other_host(self, value: str) -> None:
if value:
del self['condition']
ns = self.condition_ns
@@ -76,5 +76,5 @@ class StreamError(Error, StanzaBase):
elif self['condition'] == 'see-other-host':
del self['condition']
- def del_see_other_host(self):
+ def del_see_other_host(self) -> None:
self._del_sub('{%s}see-other-host' % self.condition_ns)