diff options
author | Philipp Hörist <philipp@hoerist.com> | 2023-08-20 12:02:09 +0300 |
---|---|---|
committer | Philipp Hörist <philipp@hoerist.com> | 2023-08-20 12:02:09 +0300 |
commit | 5da87e2e7db7a8da499e553970876d9a9a51d240 (patch) | |
tree | aaf9f0b4f082892f36d607b8861c6ac11657413d | |
parent | 92dc358efcdbe8d2014ebcde754d154848263355 (diff) |
imprv: JID: Allow comparisons against any object
-rw-r--r-- | nbxmpp/protocol.py | 13 |
1 files 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: |