Use enumerate for index and item in loop

This commit is contained in:
Pravin Kamble 2025-11-26 14:23:32 +05:30
parent 54d649b8ed
commit 681582bfcf

View File

@ -689,16 +689,14 @@ class ListSerializer(BaseSerializer):
ret = [] ret = []
errors = {} errors = {}
index = 0
for item in data: for index, item in enumerate(data):
try: try:
validated = self.run_child_validation(item) validated = self.run_child_validation(item)
except ValidationError as exc: except ValidationError as exc:
errors[index] = exc.detail errors[index] = exc.detail
else: else:
ret.append(validated) ret.append(validated)
index += 1
if errors: if errors:
raise ValidationError(errors) raise ValidationError(errors)