summaryrefslogtreecommitdiff
path: root/slixmpp/stanza/error.py
diff options
context:
space:
mode:
Diffstat (limited to 'slixmpp/stanza/error.py')
-rw-r--r--slixmpp/stanza/error.py16
1 files changed, 9 insertions, 7 deletions
diff --git a/slixmpp/stanza/error.py b/slixmpp/stanza/error.py
index 83742a5c..76c6b9cc 100644
--- a/slixmpp/stanza/error.py
+++ b/slixmpp/stanza/error.py
@@ -3,7 +3,7 @@
# This file is part of Slixmpp.
# See the file LICENSE for copying permission.
from __future__ import annotations
-from typing import Optional
+from typing import Optional, Dict, Type, ClassVar
from slixmpp.xmlstream import ElementBase, ET
@@ -50,10 +50,10 @@ class Error(ElementBase):
name = 'error'
plugin_attrib = 'error'
interfaces = {'code', 'condition', 'text', 'type',
- 'gone', 'redirect', 'by'}
+ 'gone', 'redirect', 'by'}
sub_interfaces = {'text'}
- plugin_attrib_map = {}
- plugin_tag_map = {}
+ plugin_attrib_map: ClassVar[Dict[str, Type[ElementBase]]] = {}
+ plugin_tag_map: ClassVar[Dict[str, Type[ElementBase]]] = {}
conditions = {'bad-request', 'conflict', 'feature-not-implemented',
'forbidden', 'gone', 'internal-server-error',
'item-not-found', 'jid-malformed', 'not-acceptable',
@@ -66,7 +66,7 @@ class Error(ElementBase):
condition_ns: str = 'urn:ietf:params:xml:ns:xmpp-stanzas'
types = {'cancel', 'continue', 'modify', 'auth', 'wait'}
- def setup(self, xml: Optional[ET.Element]=None):
+ def setup(self, xml: Optional[ET.Element] = None):
"""
Populate the stanza object using an optional XML object.
@@ -83,7 +83,9 @@ class Error(ElementBase):
self['type'] = 'cancel'
self['condition'] = 'feature-not-implemented'
if self.parent is not None:
- self.parent()['type'] = 'error'
+ parent = self.parent()
+ if parent:
+ parent['type'] = 'error'
def get_condition(self) -> str:
"""Return the condition element's name."""
@@ -106,7 +108,7 @@ class Error(ElementBase):
self.xml.append(ET.Element("{%s}%s" % (self.condition_ns, value)))
return self
- def del_condition(self) -> None:
+ def del_condition(self) -> Error:
"""Remove the condition element."""
for child in self.xml:
if "{%s}" % self.condition_ns in child.tag: