From c9e3936ad426907237825f31aa23825cda87330b Mon Sep 17 00:00:00 2001 From: stefaan Date: Thu, 21 Nov 2019 20:22:19 +0100 Subject: [PATCH] update Comparable class --- Chapter2/generic_search.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Chapter2/generic_search.py b/Chapter2/generic_search.py index 6e0ceb7..d5d0032 100644 --- a/Chapter2/generic_search.py +++ b/Chapter2/generic_search.py @@ -32,11 +32,11 @@ def linear_contains(iterable: Iterable[T], key: T) -> bool: class Comparable(Protocol): - def __eq__(self, other: Any) -> bool: - ... + def __eq__(self: C, other: C) -> bool: + return self == other def __lt__(self: C, other: C) -> bool: - ... + return (self < other) and self != other def __gt__(self: C, other: C) -> bool: return (not self < other) and self != other