Skip to content

Commit

Permalink
fixup! Clarify and enforce bundle FQID equality semantics (#6671)
Browse files Browse the repository at this point in the history
  • Loading branch information
nadove-ucsc committed Nov 1, 2024
1 parent ca8cd51 commit 05387cb
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/azul/indexer/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
ABCMeta,
abstractmethod,
)
from functools import (
total_ordering,
)
from itertools import (
product,
)
Expand Down Expand Up @@ -46,6 +49,7 @@
BundleVersion = str


@total_ordering
@attrs.frozen(kw_only=True, eq=False)
class BundleFQID(SupportsLessAndGreaterThan):
"""
Expand All @@ -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:
"""
Expand Down Expand Up @@ -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)

Expand Down

0 comments on commit 05387cb

Please sign in to comment.