Opened 7 years ago

Closed 7 years ago

Last modified 4 years ago

#29113 closed Cleanup/optimization (fixed)

Simplify django.forms.formsets.all_valid() and clarify docstring

Reported by: Дилян Палаузов Owned by: nobody
Component: Forms Version: dev
Severity: Normal Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

If in django.forms.formsets.all_valid() the calls to formset.is_valid() can be short-circuited, replace the body of the function with return all(formset.is_valid() for formset in formsets). Otherwise write as comment, that short-circuiting is not feasible and replace the if not formset.is_valid(): valid = False with valid &= formset.is_valid()

Change History (4)

comment:1 by Tim Graham, 7 years ago

Has patch: set
Triage Stage: UnreviewedAccepted

Short-circuiting isn't valid because all formsets must be validated. I added a test for that in 4bcec02368b7e5466f64dc17286689b16613c94b.

PR to clarify the docstring and make the simplification.

comment:2 by Tim Graham, 7 years ago

Summary: django.forms.formsets.all_valid() short circuitSimplify django.forms.formsets.all_valid() and clarify docstring

comment:3 by GitHub <noreply@…>, 7 years ago

Resolution: fixed
Status: newclosed

In 16ee53d7:

Fixed #29113 -- Simplified django.forms.formsets.all_valid() and clarified docstring.

comment:4 by GitHub <noreply@…>, 4 years ago

In b03b19b:

Refs #29113 -- Simplified formset validation.

Thanks Nick Pope for review and complement.

Note: See TracTickets for help on using tickets.
Back to Top