Skip to content

Commit

Permalink
fix: str representation of enum across python versions (#60)
Browse files Browse the repository at this point in the history
* 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]>
  • Loading branch information
PeterStaar-IBM authored Oct 29, 2024
1 parent 4993c34 commit 8528918
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions docling_core/types/doc/labels.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ class DocItemLabel(str, Enum):
PARAGRAPH = "paragraph" # explicitly a paragraph and not arbitrary text
REFERENCE = "reference"

def __str__(self):
"""Get string value."""
return str(self.value)


class GroupLabel(str, Enum):
"""GroupLabel."""
Expand All @@ -43,6 +47,10 @@ class GroupLabel(str, Enum):
SHEET = "sheet"
SLIDE = "slide"

def __str__(self):
"""Get string value."""
return str(self.value)


class TableCellLabel(str, Enum):
"""TableCellLabel."""
Expand All @@ -51,3 +59,7 @@ class TableCellLabel(str, Enum):
ROW_HEADER = "row_header"
ROW_SECTION = "row_section"
BODY = "body"

def __str__(self):
"""Get string value."""
return str(self.value)

0 comments on commit 8528918

Please sign in to comment.