Skip to content

Commit f3e8530

Browse files
committed
stop converting
1 parent f2cb6b1 commit f3e8530

File tree

2 files changed

+5
-16
lines changed

2 files changed

+5
-16
lines changed

chia/_tests/core/util/test_streamable.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -496,7 +496,7 @@ def validate_item_type(type_in: type[Any], item: object) -> bool:
496496
value_type, next(iter(item.values()))
497497
)
498498
if is_type_Enum(type_in):
499-
return validate_item_type(type_in._streamable_proxy, item)
499+
return validate_item_type(type_in._streamable_proxy, type_in._streamable_proxy(item.value)) # type: ignore[attr-defined]
500500
return isinstance(item, type_in)
501501

502502
test_object = test_class(*args)

chia/util/streamable.py

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -160,10 +160,6 @@ def convert_dict(
160160
return {key_converter(key): value_converter(value) for key, value in mapping.items()}
161161

162162

163-
def convert_enum(convert_func: ConvertFunctionType, enum: Enum) -> Any:
164-
return convert_func(enum.value)
165-
166-
167163
def convert_hex_string(item: str) -> bytes:
168164
if not isinstance(item, str):
169165
raise InvalidTypeError(str, type(item))
@@ -236,11 +232,6 @@ def function_to_convert_one_item(
236232
key_converter = function_to_convert_one_item(inner_types[0], json_parser)
237233
value_converter = function_to_convert_one_item(inner_types[1], json_parser)
238234
return lambda mapping: convert_dict(key_converter, value_converter, mapping) # type: ignore[arg-type]
239-
elif is_type_Enum(f_type):
240-
if not hasattr(f_type, "_streamable_proxy"):
241-
raise UnsupportedType(f"Using Enum ({f_type}) in streamable requires a 'streamable_enum' wrapper.")
242-
convert_func = function_to_convert_one_item(f_type._streamable_proxy, json_parser)
243-
return lambda enum: convert_enum(convert_func, enum) # type: ignore[arg-type]
244235
elif hasattr(f_type, "from_json_dict"):
245236
if json_parser is None:
246237
json_parser = f_type.from_json_dict
@@ -290,11 +281,6 @@ def function_to_post_init_process_one_item(f_type: type[object]) -> ConvertFunct
290281
key_converter = function_to_post_init_process_one_item(inner_types[0])
291282
value_converter = function_to_post_init_process_one_item(inner_types[1])
292283
return lambda mapping: convert_dict(key_converter, value_converter, mapping) # type: ignore[arg-type]
293-
if is_type_Enum(f_type):
294-
if not hasattr(f_type, "_streamable_proxy"):
295-
raise UnsupportedType(f"Using Enum ({f_type}) in streamable requires a 'streamable_enum' wrapper.")
296-
process_inner_func = function_to_post_init_process_one_item(f_type._streamable_proxy)
297-
return lambda item: convert_enum(f_type._streamable_proxy, item) # type: ignore[arg-type]
298284
return lambda item: post_init_process_item(f_type, item)
299285

300286

@@ -553,7 +539,10 @@ def function_to_stream_one_item(f_type: type[Any]) -> StreamFunctionType:
553539
elif is_type_Enum(f_type):
554540
if not hasattr(f_type, "_streamable_proxy"):
555541
raise UnsupportedType(f"Using Enum ({f_type}) in streamable requires a 'streamable_enum' wrapper.")
556-
return function_to_stream_one_item(f_type._streamable_proxy)
542+
return lambda item, f: function_to_stream_one_item(f_type._streamable_proxy)(
543+
f_type._streamable_proxy(item.value), # type: ignore[attr-defined]
544+
f,
545+
)
557546
elif f_type is str:
558547
return stream_str
559548
elif f_type is bool:

0 commit comments

Comments
 (0)