Skip to content

Commit 90fe819

Browse files
committed
Use more descriptive iteration variable names
1 parent d8d7aec commit 90fe819

File tree

1 file changed

+19
-10
lines changed

1 file changed

+19
-10
lines changed

web3/_utils/abi.py

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,7 @@ def _convert_abi_input(arg_abi, arg):
359359

360360
if isinstance(arg, abc.Mapping):
361361
# Arg is mapping. Convert to properly ordered sequence.
362-
arg = tuple(arg[c['name']] for c in sub_abis)
362+
arg = tuple(arg[abi['name']] for abi in sub_abis)
363363

364364
if not is_list_like(arg):
365365
raise TypeError(
@@ -369,7 +369,10 @@ def _convert_abi_input(arg_abi, arg):
369369
),
370370
)
371371

372-
return type(arg)(_convert_abi_input(c, a) for c, a in zip(sub_abis, arg))
372+
return type(arg)(
373+
_convert_abi_input(sub_abi, sub_arg)
374+
for sub_abi, sub_arg in zip(sub_abis, arg)
375+
)
373376

374377

375378
def get_aligned_abi_inputs(abi, args):
@@ -380,15 +383,18 @@ def get_aligned_abi_inputs(abi, args):
380383
contained in ``args`` may contain nested mappings or sequences corresponding
381384
to tuple-encoded values in ``abi``.
382385
"""
383-
inputs = abi.get('inputs', [])
386+
input_abis = abi.get('inputs', [])
384387

385388
if isinstance(args, abc.Mapping):
386389
# `args` is mapping, convert to properly ordered sequence
387-
args = tuple(args[i['name']] for i in inputs)
390+
args = tuple(args[abi['name']] for abi in input_abis)
388391

389392
return (
390-
tuple(collapse_if_tuple(i) for i in inputs),
391-
type(args)(_convert_abi_input(i, a) for i, a in zip(inputs, args)),
393+
tuple(collapse_if_tuple(abi) for abi in input_abis),
394+
type(args)(
395+
_convert_abi_input(abi, arg)
396+
for abi, arg in zip(input_abis, args)
397+
),
392398
)
393399

394400

@@ -676,13 +682,16 @@ def abi_sub_tree(abi_type: Optional[Union[TypeStr, ABIType]], data_value: Any) -
676682
# If type is array, determine item type and annotate all
677683
# items in iterable with that type
678684
item_type_str = abi_type.item_type.to_type_str()
679-
data_value = [abi_sub_tree(item_type_str, i) for i in data_value]
685+
data_value = [
686+
abi_sub_tree(item_type_str, item_value)
687+
for item_value in data_value
688+
]
680689
elif isinstance(abi_type, TupleType):
681690
# Otherwise, if type is tuple, determine component types and annotate
682-
# items in iterable respectively with those types
691+
# tuple components in iterable respectively with those types
683692
data_value = type(data_value)(
684-
abi_sub_tree(comp_type.to_type_str(), i)
685-
for comp_type, i in zip(abi_type.components, data_value)
693+
abi_sub_tree(comp_type.to_type_str(), comp_value)
694+
for comp_type, comp_value in zip(abi_type.components, data_value)
686695
)
687696

688697
return ABITypedData([

0 commit comments

Comments
 (0)