Welcome to mirror list, hosted at ThFree Co, Russian Federation.

dev.gajim.org/gajim/python-nbxmpp.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilipp Hörist <philipp@hoerist.com>2023-08-20 12:02:09 +0300
committerPhilipp Hörist <philipp@hoerist.com>2023-08-20 12:02:09 +0300
commit5da87e2e7db7a8da499e553970876d9a9a51d240 (patch)
treeaaf9f0b4f082892f36d607b8861c6ac11657413d
parent92dc358efcdbe8d2014ebcde754d154848263355 (diff)
imprv: JID: Allow comparisons against any object
-rw-r--r--nbxmpp/protocol.py13
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: