Problem
EndPoint subclasses implement __lt__ assuming the other operand has the same concrete type. Directly sorting heterogeneous endpoints can therefore fail.
from cassandra.connection import DefaultEndPoint, UnixSocketEndPoint
UnixSocketEndPoint('/tmp/cql.sock') < DefaultEndPoint('127.0.0.1')
This raises AttributeError because UnixSocketEndPoint.__lt__ reads _unix_socket_path from the DefaultEndPoint. The reverse comparison can also raise TypeError when tuple comparison reaches an integer port versus None.
The behavior predates PR #944. That PR only adds deterministic mixed ordering at the Host layer and should not broaden into a public endpoint-ordering redesign. Found while reviewing #944 (comment).
Expected behavior
Define and document one cross-type ordering contract for built-in endpoint implementations, or make heterogeneous comparison explicitly unsupported and ensure callers use a shared sort key.
Acceptance criteria
- Comparing or sorting heterogeneous built-in endpoints does not fail unexpectedly.
- Default, Unix socket, SNI, and Client Routes endpoints are covered.
- Equality, hashing, and ordering remain internally consistent.
Problem
EndPointsubclasses implement__lt__assuming the other operand has the same concrete type. Directly sorting heterogeneous endpoints can therefore fail.This raises
AttributeErrorbecauseUnixSocketEndPoint.__lt__reads_unix_socket_pathfrom theDefaultEndPoint. The reverse comparison can also raiseTypeErrorwhen tuple comparison reaches an integer port versusNone.The behavior predates PR #944. That PR only adds deterministic mixed ordering at the
Hostlayer and should not broaden into a public endpoint-ordering redesign. Found while reviewing #944 (comment).Expected behavior
Define and document one cross-type ordering contract for built-in endpoint implementations, or make heterogeneous comparison explicitly unsupported and ensure callers use a shared sort key.
Acceptance criteria