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

chore: PubSub: Add type annotations

parent 661eef28
No related branches found
No related tags found
No related merge requests found
...@@ -20,10 +20,17 @@ ...@@ -20,10 +20,17 @@
# XEP-0060: Publish-Subscribe # XEP-0060: Publish-Subscribe
from __future__ import annotations
from typing import Any
from typing import Callable
import nbxmpp import nbxmpp
from nbxmpp.namespaces import Namespace from nbxmpp.namespaces import Namespace
from nbxmpp.structs import DiscoInfo
from gajim.common import app from gajim.common import app
from gajim.common import types
from gajim.common.modules.base import BaseModule from gajim.common.modules.base import BaseModule
...@@ -38,17 +45,21 @@ class PubSub(BaseModule): ...@@ -38,17 +45,21 @@ class PubSub(BaseModule):
'get_access_model', 'get_access_model',
] ]
def __init__(self, con): def __init__(self, con: types.Client) -> None:
BaseModule.__init__(self, con) BaseModule.__init__(self, con)
self.publish_options = False self.publish_options = False
def pass_disco(self, info): def pass_disco(self, info: DiscoInfo) -> None:
if Namespace.PUBSUB_PUBLISH_OPTIONS in info.features: if Namespace.PUBSUB_PUBLISH_OPTIONS in info.features:
self._log.info('Discovered Pubsub publish options: %s', info.jid) self._log.info('Discovered Pubsub publish options: %s', info.jid)
self.publish_options = True self.publish_options = True
def send_pb_subscription_query(self, jid, cb, **kwargs): def send_pb_subscription_query(self,
jid: str,
cb: Callable[..., Any],
**kwargs: Any
) -> None:
if not app.account_is_available(self._account): if not app.account_is_available(self._account):
return return
...@@ -58,7 +69,12 @@ def send_pb_subscription_query(self, jid, cb, **kwargs): ...@@ -58,7 +69,12 @@ def send_pb_subscription_query(self, jid, cb, **kwargs):
self._con.connection.SendAndCallForResponse(query, cb, kwargs) self._con.connection.SendAndCallForResponse(query, cb, kwargs)
def send_pb_subscribe(self, jid, node, cb, **kwargs): def send_pb_subscribe(self,
jid: str,
node: str,
cb: Callable[..., Any],
**kwargs: Any
) -> None:
if not app.account_is_available(self._account): if not app.account_is_available(self._account):
return return
...@@ -69,7 +85,12 @@ def send_pb_subscribe(self, jid, node, cb, **kwargs): ...@@ -69,7 +85,12 @@ def send_pb_subscribe(self, jid, node, cb, **kwargs):
self._con.connection.SendAndCallForResponse(query, cb, kwargs) self._con.connection.SendAndCallForResponse(query, cb, kwargs)
def send_pb_unsubscribe(self, jid, node, cb, **kwargs): def send_pb_unsubscribe(self,
jid: str,
node: str,
cb: Callable[..., Any],
**kwargs: Any
) -> None:
if not app.account_is_available(self._account): if not app.account_is_available(self._account):
return return
......
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