diff --git a/sepes/_src/tree_index.py b/sepes/_src/tree_index.py index 1276213..bafbe63 100644 --- a/sepes/_src/tree_index.py +++ b/sepes/_src/tree_index.py @@ -183,6 +183,9 @@ def _(self, other: int) -> bool: def _(self, other: SequenceKeyType) -> bool: return self.idx == other.idx + def __repr__(self) -> str: + return f"{self.idx}" + class NameKey(BaseKey): def __init__(self, name: str) -> None: @@ -204,6 +207,9 @@ def _(self, other: GetAttrKeyType) -> bool: def _(self, other: DictKeyType) -> bool: return self.name == other.key + def __repr__(self) -> str: + return f"{self.name}" + class EllipsisKey(BaseKey): """Match all leaves.""" @@ -214,6 +220,9 @@ def __init__(self, _): def __eq__(self, _: KeyEntry) -> bool: return True + def __repr__(self) -> str: + return "..." + class MultiKey(BaseKey): """Match a leaf with multiple keys at the same level.""" @@ -264,6 +273,9 @@ def _(self, other) -> bool: def _(self, other) -> bool: return re.fullmatch(self.pattern, other.key) is not None + def __repr__(self) -> str: + return f"{self.pattern}" + # dispatch on type of indexer to convert input item to at indexer # `__getitem__` to the appropriate key