Skip to content

Commit

Permalink
feat: equality non-hashable
Browse files Browse the repository at this point in the history
  • Loading branch information
eturino committed Jul 29, 2021
1 parent 3362cf7 commit e685dd9
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions key_set/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,10 @@ def clone(self) -> KeySetNone:
class KeySetSome(KeySet):
"""Represents the SOME sets: a concrete set (`A ⊂ 𝕌`)."""

def __init__(self, elements: set[str]):
"""Requires the set of elements of the concrete set."""
self._elements = set(elements)

def __eq__(self, other):
"""Returns True if `other` is KeySetSome."""
if not isinstance(other, KeySet):
Expand All @@ -129,10 +133,6 @@ def __eq__(self, other):
return isinstance(other, KeySetSome) and \
self._elements == other.elements()

def __init__(self, elements: set[str]):
"""Requires the set of elements of the concrete set."""
self._elements = set(elements)

def key_set_type(self) -> KeySetType:
"""Returns the KeySetType that describes the set."""
return KeySetType.SOME
Expand Down Expand Up @@ -160,6 +160,10 @@ class KeySetAllExceptSome(KeySet):
Includes all the elements except the given ones (`A' = {x ∈ 𝕌 | x ∉ A}`).
"""

def __init__(self, elements: set[str]):
"""Requires the set of elements of the concrete set."""
self._elements = set(elements)

def __eq__(self, other):
"""Returns True if `other` is KeySetAllExceptSome."""
if not isinstance(other, KeySet):
Expand All @@ -169,10 +173,6 @@ def __eq__(self, other):
return isinstance(other, KeySetAllExceptSome) and \
self._elements == other.elements()

def __init__(self, elements: set[str]):
"""Requires the set of elements of the concrete set."""
self._elements = set(elements)

def key_set_type(self) -> KeySetType:
"""Returns the KeySetType that describes the set."""
return KeySetType.ALL_EXCEPT_SOME
Expand Down

0 comments on commit e685dd9

Please sign in to comment.