diff --git a/libervia/backend/memory/disco.py b/libervia/backend/memory/disco.py index eeb70cd2..696715e1 100755 --- a/libervia/backend/memory/disco.py +++ b/libervia/backend/memory/disco.py @@ -18,7 +18,7 @@ # along with this program. If not, see . from collections.abc import Iterable -from typing import cast +from typing import TYPE_CHECKING, cast from twisted.internet.interfaces import IReactorCore from libervia.backend import G @@ -40,6 +40,9 @@ import time from libervia.backend.tools.utils import ensure_deferred +if TYPE_CHECKING: + from libervia.backend.core.main import LiberviaBackend + log = getLogger(__name__) @@ -73,6 +76,10 @@ class HashManager: if hash_ in self.hashes: log.debug("ignoring hash set: it is already known") return + if disco_info is None: + msg = f"Cannot cache 'None' for hash {hash_}" + log.exception(msg) + raise exceptions.InternalError(msg) self.hashes[hash_] = disco_info self.persistent[hash_] = disco_info.toElement().toXml() @@ -107,7 +114,7 @@ class HashManager: class Discovery: """Manage capabilities of entities""" - def __init__(self, host): + def __init__(self, host: "LiberviaBackend"): self.host = host # JID-based disco info cache, it is used for entities without XEP-0115 support or # when something goes wrong with hash validation.