changeset 3815:853cbaf56e9e

plugin XEP-0060: type hints
author Goffi <goffi@goffi.org>
date Wed, 29 Jun 2022 11:36:31 +0200
parents 4edfd7521418
children 213e83a4ed10
files sat/plugins/plugin_xep_0060.py
diffstat 1 files changed, 25 insertions(+), 16 deletions(-) [+]
line wrap: on
line diff
--- a/sat/plugins/plugin_xep_0060.py	Wed Jun 29 10:17:33 2022 +0200
+++ b/sat/plugins/plugin_xep_0060.py	Wed Jun 29 11:36:31 2022 +0200
@@ -17,26 +17,28 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 
-from typing import Optional, List, Tuple, Dict, Union
 from collections import namedtuple
-import urllib.request, urllib.parse, urllib.error
 from functools import reduce
-from zope.interface import implementer
+from typing import Any, Dict, List, Optional, Tuple, Union
+import urllib.error
+import urllib.parse
+import urllib.request
+
+from twisted.internet import defer, reactor
+from twisted.words.protocols.jabber import error, jid
 from twisted.words.xish import domish
-from twisted.words.protocols.jabber import jid, error
-from twisted.internet import reactor, defer
 from wokkel import disco
 from wokkel import data_form
-# XXX: sat_tmp.wokkel.pubsub is actually use instead of wokkel version
-#      mam and rsm come from sat_tmp.wokkel too
 from wokkel import pubsub
 from wokkel import rsm
 from wokkel import mam
+from zope.interface import implementer
+
+from sat.core import exceptions
+from sat.core.constants import Const as C
+from sat.core.core_types import SatXMPPEntity
 from sat.core.i18n import _
-from sat.core.constants import Const as C
 from sat.core.log import getLogger
-from sat.core.core_types import SatXMPPEntity
-from sat.core import exceptions
 from sat.tools import utils
 from sat.tools import sat_defer
 from sat.tools import xml_tools
@@ -558,15 +560,22 @@
         except IndexError:
             return item_id
 
-    async def sendItems(self, client, service, nodeIdentifier, items, extra=None):
+    async def sendItems(
+        self,
+        client: SatXMPPEntity,
+        service: jid.JID,
+        nodeIdentifier: str,
+        items: List[domish.Element],
+        extra: Optional[Dict[str, Any]] = None
+    ) -> List[str]:
         """High level method to send several items at once
 
-        @param service(jid.JID, None): service to send the item to
+        @param service: service to send the item to
             None to use PEP
-        @param NodeIdentifier(unicode): PubSub node to use
-        @param items(list[domish.Element]): whole item elements to send,
+        @param NodeIdentifier: PubSub node to use
+        @param items: whole item elements to send,
             "id" will be used if set
-        @param extra(dict, None): extra options. Key can be:
+        @param extra: extra options. Key can be:
             - self.EXTRA_PUBLISH_OPTIONS(dict): publish options, cf. XEP-0060 ยง 7.1.5
                 the dict maps option name to value(s)
             - self.EXTRA_ON_PRECOND_NOT_MET(str): policy to have when publishing is
@@ -575,7 +584,7 @@
                 * publish_without_options: re-publish without the publish-options.
                     A warning will be logged showing that the publish-options could not
                     be used
-        @return (list[unicode]): ids of the created items
+        @return: ids of the created items
         """
         if extra is None:
             extra = {}