enumerate was accidentally listed in consuming functions, but it only creates an iterator so it is not safe to omit the list() in enumerate(list(d.keys())) unless that iterator itself is called by a consuming function.
This commit makes enumerate an iterator function (like iter) instead of a consuming function (like sorted).
This commit also recursively looks at the parent when d.items(), d.keys(), or d.values() is called from an iterator function to see whether the list() can be omitted. For example, sorted(iter(iter(iter(d.keys())))) does not need `list()
Description
enumerate was accidentally listed in consuming functions, but it only creates an iterator so it is not safe to omit the list() in enumerate(list(d.keys())) unless that iterator itself is called by a consuming function.
This commit makes
enumerate
an iterator function (likeiter
) instead of a consuming function (likesorted
).This commit also recursively looks at the parent when
d.items()
,d.keys()
, ord.values()
is called from an iterator function to see whether thelist()
can be omitted. For example,sorted(iter(iter(iter(d.keys()))))
does not need `list()Fixes: #47