From b6464d3498a34d9116aecc7cf53cbd3133e2bca4 Mon Sep 17 00:00:00 2001 From: salt-die <53280662+salt-die@users.noreply.github.com> Date: Tue, 5 Dec 2023 01:11:17 -0600 Subject: [PATCH] Add `__bool__`. --- src/mind_the_gaps/gaps.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/mind_the_gaps/gaps.py b/src/mind_the_gaps/gaps.py index 8ecab58..ca61975 100644 --- a/src/mind_the_gaps/gaps.py +++ b/src/mind_the_gaps/gaps.py @@ -249,6 +249,9 @@ def __xor__(self, other: Self) -> Self: def __sub__(self, other: Self) -> Self: return Gaps(_merge(self.endpoints, other.endpoints, sub)) + def __bool__(self): + return len(self.endpoints) > 0 + def __contains__(self, value: T) -> bool: i = bisect(self.endpoints, value, key=attrgetter("value")) if i == 0: