Skip to content

Commit 4f3d094

Browse files
hohodesenfans
andcommitted
Update src/aleph/sdk/utils.py
Co-authored-by: Olivier Desenfans <[email protected]>
1 parent 094d703 commit 4f3d094

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/aleph/sdk/utils.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,10 @@ def enum_as_str(obj: Union[str, Enum]) -> str:
8585
Python 3.11 adds a new formatting of string enums.
8686
`str(MyEnum.value)` becomes `MyEnum.value` instead of `value`.
8787
"""
88-
if isinstance(obj, str):
89-
return obj
90-
else:
91-
assert isinstance(obj, Enum)
88+
if not isinstance(obj, str):
89+
raise TypeError(f"Unsupported enum type: {type(obj)}")
90+
91+
if isinstance(obj, Enum):
9292
return obj.value
93+
94+
return obj

0 commit comments

Comments
 (0)