From 05387cbe8940c053ea139c8428756a7435266d01 Mon Sep 17 00:00:00 2001 From: Noa Aviel Dove Date: Fri, 1 Nov 2024 14:41:17 -0700 Subject: [PATCH] fixup! Clarify and enforce bundle FQID equality semantics (#6671) --- src/azul/indexer/__init__.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/azul/indexer/__init__.py b/src/azul/indexer/__init__.py index dc4172c5d..0c96e479a 100644 --- a/src/azul/indexer/__init__.py +++ b/src/azul/indexer/__init__.py @@ -2,6 +2,9 @@ ABCMeta, abstractmethod, ) +from functools import ( + total_ordering, +) from itertools import ( product, ) @@ -46,6 +49,7 @@ BundleVersion = str +@total_ordering @attrs.frozen(kw_only=True, eq=False) class BundleFQID(SupportsLessAndGreaterThan): """ @@ -67,7 +71,8 @@ def _nucleus(self) -> tuple[str, str]: # their inheritance relationships or how their attributes are annotated # (e.g. specifying `eq=False` has no effect). We want instances of # all subclasses to compare equal as long as `uuid` and `version` are - # equal. + # equal. For the same reason, we can't use `typing.Self` in the signature + # because it would constrain the RHS to instances of subclasses of the LHS. @final def __eq__(self, other: 'BundleFQID') -> bool: """ @@ -143,9 +148,6 @@ def __lt__(self, other: 'BundleFQID') -> bool: """ return self._nucleus() < other._nucleus() - def __gt__(self, other: 'BundleFQID'): - return self._nucleus() > other._nucleus() - def to_json(self) -> MutableJSON: return attrs.asdict(self, recurse=False)