From 5da87e2e7db7a8da499e553970876d9a9a51d240 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philipp=20H=C3=B6rist?= Date: Sun, 20 Aug 2023 11:02:09 +0200 Subject: imprv: JID: Allow comparisons against any object --- nbxmpp/protocol.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/nbxmpp/protocol.py b/nbxmpp/protocol.py index 48c8e99..0ad8e9b 100644 --- a/nbxmpp/protocol.py +++ b/nbxmpp/protocol.py @@ -713,18 +713,21 @@ class JID: def __hash__(self): return hash(str(self)) - def __eq__(self, other: Union[str, JID]) -> bool: + def __eq__(self, other: object) -> bool: if isinstance(other, str): try: return JID.from_string(other) == self except Exception: return False - return (self.localpart == other.localpart and - self.domain == other.domain and - self.resource == other.resource) + if isinstance(other, JID): + return (self.localpart == other.localpart and + self.domain == other.domain and + self.resource == other.resource) - def __ne__(self, other: Union[str, JID]) -> bool: + return False + + def __ne__(self, other: object) -> bool: return not self.__eq__(other) def domain_to_ascii(self) -> str: -- cgit v1.2.3