[Django] #29113: django.forms.formsets.all_valid() short circuit

7 views
Skip to first unread message

Django

unread,
Feb 5, 2018, 3:18:09 AM2/5/18
to django-...@googlegroups.com
#29113: django.forms.formsets.all_valid() short circuit
------------------------------------------------+------------------------
Reporter: Дилян Палаузов | Owner: nobody
Type: Cleanup/optimization | Status: new
Component: Forms | Version: master
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
------------------------------------------------+------------------------
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()}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/29113>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Feb 5, 2018, 9:49:06 AM2/5/18
to django-...@googlegroups.com
#29113: django.forms.formsets.all_valid() short circuit
--------------------------------------+------------------------------------

Reporter: Дилян Палаузов | Owner: nobody
Type: Cleanup/optimization | Status: new
Component: Forms | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
--------------------------------------+------------------------------------
Changes (by Tim Graham):

* has_patch: 0 => 1
* stage: Unreviewed => Accepted


Comment:

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

[https://github.com/django/django/pull/9663 PR] to clarify the docstring
and make the simplification.

--
Ticket URL: <https://code.djangoproject.com/ticket/29113#comment:1>

Django

unread,
Feb 5, 2018, 9:50:19 AM2/5/18
to django-...@googlegroups.com
#29113: Simplify django.forms.formsets.all_valid() and clarify docstring
--------------------------------------+------------------------------------

Reporter: Дилян Палаузов | Owner: nobody
Type: Cleanup/optimization | Status: new
Component: Forms | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
--------------------------------------+------------------------------------

--
Ticket URL: <https://code.djangoproject.com/ticket/29113#comment:2>

Django

unread,
Feb 5, 2018, 10:29:55 AM2/5/18
to django-...@googlegroups.com
#29113: Simplify django.forms.formsets.all_valid() and clarify docstring
--------------------------------------+------------------------------------
Reporter: Дилян Палаузов | Owner: nobody
Type: Cleanup/optimization | Status: closed
Component: Forms | Version: master
Severity: Normal | Resolution: fixed
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
--------------------------------------+------------------------------------
Changes (by GitHub <noreply@…>):

* status: new => closed
* resolution: => fixed


Comment:

In [changeset:"16ee53d7bb01819859c78a88e3fc93eda985f71a" 16ee53d7]:
{{{
#!CommitTicketReference repository=""
revision="16ee53d7bb01819859c78a88e3fc93eda985f71a"
Fixed #29113 -- Simplified django.forms.formsets.all_valid() and clarified
docstring.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/29113#comment:3>

Django

unread,
Nov 3, 2020, 3:57:23 AM11/3/20
to django-...@googlegroups.com
#29113: Simplify django.forms.formsets.all_valid() and clarify docstring
--------------------------------------+------------------------------------
Reporter: Дилян Палаузов | Owner: nobody
Type: Cleanup/optimization | Status: closed
Component: Forms | Version: master

Severity: Normal | Resolution: fixed
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
--------------------------------------+------------------------------------

Comment (by GitHub <noreply@…>):

In [changeset:"b03b19b585a0a3685d48dae95d060d13ff4755fa" b03b19b]:
{{{
#!CommitTicketReference repository=""
revision="b03b19b585a0a3685d48dae95d060d13ff4755fa"
Refs #29113 -- Simplified formset validation.

Thanks Nick Pope for review and complement.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/29113#comment:4>

Reply all
Reply to author
Forward
0 new messages