From bc04da256a0553fbbacf57477d531e96efd19241 Mon Sep 17 00:00:00 2001 From: mathieui Date: Sat, 6 Feb 2021 18:05:59 +0100 Subject: XEP-0045: Types, visibility, and documentation - Make all handlers private (_-prefixed) - Reorder methods in a more thematic order - Add docstrings to public methods - Add types where they were missing - Create new Literal types for closed enums - Make join_muc a wrapper around join_muc_wait and return a Future - Deprecate the current join_muc API - Fix some mypy issues --- slixmpp/types.py | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) (limited to 'slixmpp/types.py') diff --git a/slixmpp/types.py b/slixmpp/types.py index 44e24a1e..c8ab640c 100644 --- a/slixmpp/types.py +++ b/slixmpp/types.py @@ -7,15 +7,21 @@ This file contains boilerplate to define types relevant to slixmpp. """ +from typing import Optional + try: from typing import ( Literal, + TypedDict, ) except ImportError: from typing_extensions import ( Literal, + TypedDict, ) +from slixmpp.jid import JID + PresenceTypes = Literal[ 'error', 'probe', 'subscribe', 'subscribed', 'unavailable', 'unsubscribe', 'unsubscribed', @@ -35,3 +41,32 @@ IqTypes = Literal[ "error", "get", "set", "result", ] +MucRole = Literal[ + 'moderator', 'participant', 'visitor', 'none' +] + +MucAffiliation = Literal[ + 'outcast', 'member', 'admin', 'owner', 'none' +] + + +class PresenceArgs(TypedDict, total=False): + pfrom: JID + pto: JID + pshow: PresenceShows + ptype: PresenceTypes + pstatus: str + + +class MucRoomItem(TypedDict, total=False): + jid: JID + role: MucRole + affiliation: MucAffiliation + show: Optional[PresenceShows] + status: str + alt_nick: str + + +MucRoomItemKeys = Literal[ + 'jid', 'role', 'affiliation', 'show', 'status', 'alt_nick', +] -- cgit v1.2.3