From b6fe0d424f4c676e6f6defd5540a6cf866a1c811 Mon Sep 17 00:00:00 2001 From: svalee Date: Thu, 16 May 2019 01:25:58 +0300 Subject: [PATCH] Added equality check for Connection class (#938) * Added equality check for Connection class * ES: make connection hashable --- elasticsearch/connection/base.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/elasticsearch/connection/base.py b/elasticsearch/connection/base.py index 4404ed7f..cb4a8116 100644 --- a/elasticsearch/connection/base.py +++ b/elasticsearch/connection/base.py @@ -56,6 +56,16 @@ class Connection(object): def __repr__(self): return "<%s: %s>" % (self.__class__.__name__, self.host) + def __eq__(self, other): + if not isinstance(other, Connection): + raise TypeError( + "Unsupported equality check for %s and %s" % (self, other) + ) + return True + + def __hash__(self): + return id(self) + def _pretty_json(self, data): # pretty JSON in tracer curl logs try: