Skip to content

Commit b01cd33

Browse files
author
pacrob
committed
clean up typing per comments
1 parent 8a443af commit b01cd33

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

web3/_utils/abi.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -909,12 +909,10 @@ def build_strict_registry() -> ABIRegistry:
909909
return registry
910910

911911

912+
# Sequence[ABIFunctionParams],
912913
def named_tree(
913-
abi: Union[
914-
Sequence[ABIFunctionParams],
915-
Iterable[Union[ABIFunction, ABIEvent, Dict[TypeStr, Any]]],
916-
],
917-
data: Tuple[Any, ...],
914+
abi: Iterable[Union[ABIFunctionParams, ABIFunction, ABIEvent, Dict[TypeStr, Any]]],
915+
data: Iterable[Tuple[Any, ...]],
918916
) -> Dict[str, Any]:
919917
"""
920918
Convert function inputs/outputs or event data tuple to dict with names from ABI.
@@ -926,8 +924,7 @@ def named_tree(
926924

927925

928926
def named_subtree(
929-
# TODO make this a better type
930-
abi: Any,
927+
abi: Union[ABIFunctionParams, ABIFunction, ABIEvent, Dict[TypeStr, Any]],
931928
data: Tuple[Any, ...],
932929
) -> Union[Dict[str, Any], Tuple[Any, ...], Any]:
933930
abi_type = parse(collapse_if_tuple(dict(abi)))
@@ -938,7 +935,8 @@ def named_subtree(
938935
items = [named_subtree(item_abi, item) for item in data]
939936
return items
940937

941-
if isinstance(abi_type, TupleType):
938+
elif isinstance(abi_type, TupleType):
939+
abi = cast(ABIFunctionParams, abi)
942940
names = [item["name"] for item in abi["components"]]
943941
items = [named_subtree(*item) for item in zip(abi["components"], data)]
944942

0 commit comments

Comments
 (0)