Skip to content

Commit b6fe0d4

Browse files
paulefoefxdgear
authored andcommitted
Added equality check for Connection class (#938)
* Added equality check for Connection class * ES: make connection hashable
1 parent 8ab66b9 commit b6fe0d4

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

elasticsearch/connection/base.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,16 @@ def __init__(
5656
def __repr__(self):
5757
return "<%s: %s>" % (self.__class__.__name__, self.host)
5858

59+
def __eq__(self, other):
60+
if not isinstance(other, Connection):
61+
raise TypeError(
62+
"Unsupported equality check for %s and %s" % (self, other)
63+
)
64+
return True
65+
66+
def __hash__(self):
67+
return id(self)
68+
5969
def _pretty_json(self, data):
6070
# pretty JSON in tracer curl logs
6171
try:

0 commit comments

Comments
 (0)