changeset 3916:40d47cc29ea4

plugin XEP-0300: type hints
author Goffi <goffi@goffi.org>
date Thu, 06 Oct 2022 15:19:08 +0200
parents 287938675461
children 626629781a53
files sat/plugins/plugin_xep_0300.py
diffstat 1 files changed, 18 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/sat/plugins/plugin_xep_0300.py	Thu Oct 06 14:59:49 2022 +0200
+++ b/sat/plugins/plugin_xep_0300.py	Thu Oct 06 15:19:08 2022 +0200
@@ -17,21 +17,24 @@
 # You should have received a copy of the GNU Affero General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
+from typing import Tuple
+import base64
+from collections import OrderedDict
+import hashlib
+
+from twisted.internet import threads
+from twisted.internet import defer
+from twisted.words.protocols.jabber.xmlstream import XMPPHandler
+from twisted.words.xish import domish
+from wokkel import disco, iwokkel
+from zope.interface import implementer
+
+from sat.core import exceptions
+from sat.core.constants import Const as C
 from sat.core.i18n import _
-from sat.core.constants import Const as C
 from sat.core.log import getLogger
 
 log = getLogger(__name__)
-from sat.core import exceptions
-from twisted.words.xish import domish
-from twisted.words.protocols.jabber.xmlstream import XMPPHandler
-from twisted.internet import threads
-from twisted.internet import defer
-from zope.interface import implementer
-from wokkel import disco, iwokkel
-from collections import OrderedDict
-import hashlib
-import base64
 
 
 PLUGIN_INFO = {
@@ -61,6 +64,7 @@
             ("sha-512", hashlib.sha512),
         )
     )
+    ALGO_DEFAULT = ALGO_DEFAULT
 
     def __init__(self, host):
         log.info(_("plugin Hashes initialization"))
@@ -176,12 +180,12 @@
         hash_elt["algo"] = algo
         return hash_elt
 
-    def parseHashElt(self, parent):
+    def parseHashElt(self, parent: domish.Element) -> Tuple[str, bytes]:
         """Find and parse a hash element
 
         if multiple elements are found, the strongest managed one is returned
-        @param (domish.Element): parent of <hash/> element
-        @return (tuple[str, bytes]): (algo, hash) tuple
+        @param parent: parent of <hash/> element
+        @return: (algo, hash) tuple
             both values can be None if <hash/> is empty
         @raise exceptions.NotFound: the element is not present
         @raise exceptions.DataError: the element is invalid