Skip to content

Commit 8528918

Browse files
fix: str representation of enum across python versions (#60)
* fix: enforce consistent output across linux, macos and windows Signed-off-by: Peter Staar <[email protected]> * reformat docling-core Signed-off-by: Peter Staar <[email protected]> * added __str__ to enum class and removed the .name from function Signed-off-by: Peter Staar <[email protected]> --------- Signed-off-by: Peter Staar <[email protected]>
1 parent 4993c34 commit 8528918

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

docling_core/types/doc/labels.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@ class DocItemLabel(str, Enum):
2929
PARAGRAPH = "paragraph" # explicitly a paragraph and not arbitrary text
3030
REFERENCE = "reference"
3131

32+
def __str__(self):
33+
"""Get string value."""
34+
return str(self.value)
35+
3236

3337
class GroupLabel(str, Enum):
3438
"""GroupLabel."""
@@ -43,6 +47,10 @@ class GroupLabel(str, Enum):
4347
SHEET = "sheet"
4448
SLIDE = "slide"
4549

50+
def __str__(self):
51+
"""Get string value."""
52+
return str(self.value)
53+
4654

4755
class TableCellLabel(str, Enum):
4856
"""TableCellLabel."""
@@ -51,3 +59,7 @@ class TableCellLabel(str, Enum):
5159
ROW_HEADER = "row_header"
5260
ROW_SECTION = "row_section"
5361
BODY = "body"
62+
63+
def __str__(self):
64+
"""Get string value."""
65+
return str(self.value)

0 commit comments

Comments
 (0)