Skip to content

Commit 52cefbf

Browse files
author
Val Brodsky
committed
Add __repr__ to identifiables
1 parent 4e54d49 commit 52cefbf

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

labelbox/schema/identifiables.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ def __init__(self, iterable, id_type: IdType):
2828
def __iter__(self):
2929
return iter(self._iterable)
3030

31+
def __repr__(self) -> str:
32+
return f"{self.__class__.__name__}({self._iterable})"
33+
3134

3235
class UniqueIds(Identifiables):
3336
"""

tests/unit/test_unit_identifiables.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,13 @@ def test_global_keys():
1313
identifiables = GlobalKeys(ids)
1414
assert [i for i in identifiables] == ids
1515
assert identifiables._id_type == "GKEY"
16+
17+
18+
def test_repr():
19+
ids = ["a", "b", "c"]
20+
identifiables = GlobalKeys(ids)
21+
assert repr(identifiables) == "GlobalKeys(['a', 'b', 'c'])"
22+
23+
ids = ["a", "b", "c"]
24+
identifiables = UniqueIds(ids)
25+
assert repr(identifiables) == "UniqueIds(['a', 'b', 'c'])"

0 commit comments

Comments
 (0)