Skip to content
Snippets Groups Projects
Commit 4a04c5aa authored by Daniel Brötzmann's avatar Daniel Brötzmann
Browse files

chore: Misc: Add type annotations

parent 6feac48c
No related branches found
No related tags found
No related merge requests found
......@@ -14,19 +14,25 @@
# All XEPs that don’t need their own module
from typing import Optional
import logging
from nbxmpp.structs import MessageProperties
from gajim.common.helpers import AdditionalDataDict
from gajim.common.i18n import get_rfc5646_lang
log = logging.getLogger('gajim.c.m.misc')
# XEP-0066: Out of Band Data
def parse_oob(properties, additional_data):
def parse_oob(properties: MessageProperties,
additional_data: AdditionalDataDict
) -> None:
if not properties.is_oob:
return
assert properties.oob is not None
additional_data.set_value('gajim', 'oob_url', properties.oob.url)
if properties.oob.desc is not None:
additional_data.set_value('gajim', 'oob_desc',
......@@ -34,18 +40,20 @@ def parse_oob(properties, additional_data):
# XEP-0308: Last Message Correction
def parse_correction(properties):
def parse_correction(properties: MessageProperties) -> Optional[str]:
if not properties.is_correction:
return None
assert properties.correction is not None
return properties.correction.id
# XEP-0071: XHTML-IM
def parse_xhtml(properties, additional_data):
def parse_xhtml(properties: MessageProperties,
additional_data: AdditionalDataDict
) -> None:
if not properties.has_xhtml:
return
assert properties.xhtml is not None
body = properties.xhtml.get_body(get_rfc5646_lang())
additional_data.set_value('gajim', 'xhtml', body)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment