Skip to content

Commit 1bb3de3

Browse files
committed
fix red stuff
1 parent 8a7bef1 commit 1bb3de3

File tree

3 files changed

+7
-3
lines changed

3 files changed

+7
-3
lines changed

tests/core/utilities/test_abi.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ def test_get_tuple_type_str_parts(
262262
def test_abi_data_tree(
263263
types: List[str], data: Tuple[List[bool], bytes], expected: List[Any]
264264
) -> None:
265-
assert abi_data_tree(types, data) == expected
265+
assert list(abi_data_tree(types, data)) == expected
266266

267267

268268
@pytest.mark.parametrize(

web3/_utils/abi.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -624,7 +624,7 @@ def normalizer(datatype, data):
624624
@curry
625625
def abi_data_tree(
626626
types: Iterable[TypeStr], data: Iterable[Any]
627-
) -> List["ABITypedData"]:
627+
) -> "map[ABITypedData]":
628628
"""
629629
Decorate the data tree with pairs of (type, data). The pair tuple is actually an
630630
ABITypedData, but can be accessed as a tuple.
@@ -634,7 +634,7 @@ def abi_data_tree(
634634
>>> abi_data_tree(types=["bool[2]", "uint"], data=[[True, False], 0])
635635
[("bool[2]", [("bool", True), ("bool", False)]), ("uint256", 0)]
636636
"""
637-
return list(map(abi_sub_tree, types, data))
637+
return map(abi_sub_tree, types, data)
638638

639639

640640
@curry
@@ -929,6 +929,8 @@ async def async_map_if_collection(
929929
If the value is not a collection, return it unmodified.
930930
"""
931931
datatype = type(value)
932+
if datatype is map:
933+
return [await func(item) for item in value]
932934
if isinstance(value, Mapping):
933935
return datatype({key: await func(val) for key, val in value.values()})
934936
if is_string(value):

web3/_utils/formatters.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@ def map_collection(func: Callable[..., TReturn], collection: Any) -> Any:
6565
If the value is not a collection, return it unmodified
6666
"""
6767
datatype = type(collection)
68+
if datatype is map:
69+
return map(func, collection)
6870
if isinstance(collection, Mapping):
6971
return datatype((key, func(val)) for key, val in collection.items())
7072
if is_string(collection):

0 commit comments

Comments
 (0)