diff --git a/django/contrib/admindocs/utils.py b/django/contrib/admindocs/utils.py index bc0a3bca54..1ce4594501 100644 --- a/django/contrib/admindocs/utils.py +++ b/django/contrib/admindocs/utils.py @@ -166,7 +166,7 @@ def replace_named_groups(pattern): for start, end, group_name in named_group_indices: # Handle nested parentheses, e.g. '^(?P(x|y))/b'. unmatched_open_brackets, prev_char = 1, None - for idx, val in enumerate(list(pattern[end:])): + for idx, val in enumerate(pattern[end:]): # If brackets are balanced, the end of the string for the current # named capture group pattern has been reached. if unmatched_open_brackets == 0: @@ -200,7 +200,7 @@ def replace_unnamed_groups(pattern): for start in unnamed_group_indices: # Handle nested parentheses, e.g. '^b/((x|y)\w+)$'. unmatched_open_brackets, prev_char = 1, None - for idx, val in enumerate(list(pattern[start + 1:])): + for idx, val in enumerate(pattern[start + 1:]): if unmatched_open_brackets == 0: group_indices.append((start, start + 1 + idx)) break