Skip to content

Commit

Permalink
chore: Avoid unnecessary assignment before for-loop
Browse files Browse the repository at this point in the history
  • Loading branch information
jpmckinney committed Sep 28, 2024
1 parent 23e36e9 commit 5423b12
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions pelican/util/getter.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,9 +192,7 @@ def get_values(item: Any, str_path: str, *, value_only: bool | None = False) ->
if type(item[key]) is list:
result = []
for index, list_item in enumerate(item[key]):
values = get_values(list_item, ".".join(path[1:]), value_only=value_only)

for value in values:
for value in get_values(list_item, ".".join(path[1:]), value_only=value_only):
if value_only:
result.append(value)
elif value and "path" in value:
Expand Down Expand Up @@ -231,9 +229,7 @@ def get_values(item: Any, str_path: str, *, value_only: bool | None = False) ->
):
result = []

values = get_values(item[field][index], ".".join(path[1:]), value_only=value_only)

for value in values:
for value in get_values(item[field][index], ".".join(path[1:]), value_only=value_only):
if value_only:
result.append(value)
elif value and "path" in value:
Expand Down

0 comments on commit 5423b12

Please sign in to comment.