Skip to content

Commit f60cedc

Browse files
philogicaeMHHukiewitz
authored andcommitted
Revert fix on enum_as_str
1 parent 6a90fe3 commit f60cedc

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

src/aleph/sdk/chains/common.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ def get_verification_buffer(message: Dict) -> bytes:
2727
# Convert Enum values to strings
2828
return "\n".join(
2929
(
30-
enum_as_str(message["chain"]),
30+
enum_as_str(message["chain"]) or "",
3131
message["sender"],
32-
enum_as_str(message["type"]),
32+
enum_as_str(message["type"]) or "",
3333
message["item_hash"],
3434
)
3535
).encode()

src/aleph/sdk/utils.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -115,14 +115,14 @@ async def copy_async_readable_to_buffer(
115115
buffer.write(chunk)
116116

117117

118-
def enum_as_str(obj: Optional[Union[str, Enum]]) -> str:
118+
def enum_as_str(obj: Optional[Union[str, Enum]]) -> Optional[str]:
119119
"""Returns the value of an Enum, or the string itself when passing a string.
120120
121121
Python 3.11 adds a new formatting of string enums.
122122
`str(MyEnum.value)` becomes `MyEnum.value` instead of `value`.
123123
"""
124-
if obj is None:
125-
return ""
124+
if not obj:
125+
return None
126126
if not isinstance(obj, str):
127127
raise TypeError(f"Unsupported enum type: {type(obj)}")
128128

0 commit comments

Comments
 (0)