summaryrefslogtreecommitdiff
path: root/django/forms
diff options
context:
space:
mode:
authorNick Pope <nick.pope@flightdataservices.com>2017-12-11 12:08:45 +0000
committerTim Graham <timograham@gmail.com>2017-12-11 07:08:45 -0500
commitd13a9e44ded4e93570c6ba42ec84e45ddca2505b (patch)
tree0df16e6538d8794c39bd62b5a46879b8abe6572c /django/forms
parenta9e5ac823df8ba8b786b6450c967ca378c008d0e (diff)
Fixed #28909 -- Simplified code using tuple/list/set/dict unpacking.
Diffstat (limited to 'django/forms')
-rw-r--r--django/forms/boundfield.py2
-rw-r--r--django/forms/fields.py3
-rw-r--r--django/forms/models.py4
-rw-r--r--django/forms/widgets.py5
4 files changed, 4 insertions, 10 deletions
diff --git a/django/forms/boundfield.py b/django/forms/boundfield.py
index dba54e588a..27e80c65e7 100644
--- a/django/forms/boundfield.py
+++ b/django/forms/boundfield.py
@@ -153,7 +153,7 @@ class BoundField:
if id_:
id_for_label = widget.id_for_label(id_)
if id_for_label:
- attrs = dict(attrs or {}, **{'for': id_for_label})
+ attrs = {**(attrs or {}), 'for': id_for_label}
if self.field.required and hasattr(self.form, 'required_css_class'):
attrs = attrs or {}
if 'class' in attrs:
diff --git a/django/forms/fields.py b/django/forms/fields.py
index 64124844f0..92a8f768c4 100644
--- a/django/forms/fields.py
+++ b/django/forms/fields.py
@@ -4,7 +4,6 @@ Field classes.
import copy
import datetime
-import itertools
import math
import os
import re
@@ -112,7 +111,7 @@ class Field:
messages.update(error_messages or {})
self.error_messages = messages
- self.validators = list(itertools.chain(self.default_validators, validators))
+ self.validators = [*self.default_validators, *validators]
super().__init__()
diff --git a/django/forms/models.py b/django/forms/models.py
index 3ba7725d53..84a07a275f 100644
--- a/django/forms/models.py
+++ b/django/forms/models.py
@@ -564,9 +564,7 @@ class BaseModelFormSet(BaseFormSet):
queryset=None, *, initial=None, **kwargs):
self.queryset = queryset
self.initial_extra = initial
- defaults = {'data': data, 'files': files, 'auto_id': auto_id, 'prefix': prefix}
- defaults.update(kwargs)
- super().__init__(**defaults)
+ super().__init__(**{'data': data, 'files': files, 'auto_id': auto_id, 'prefix': prefix, **kwargs})
def initial_form_count(self):
"""Return the number of forms that are required in this FormSet."""
diff --git a/django/forms/widgets.py b/django/forms/widgets.py
index ba8287cd97..c20c8f1b50 100644
--- a/django/forms/widgets.py
+++ b/django/forms/widgets.py
@@ -241,10 +241,7 @@ class Widget(metaclass=MediaDefiningClass):
def build_attrs(self, base_attrs, extra_attrs=None):
"""Build an attribute dictionary."""
- attrs = base_attrs.copy()
- if extra_attrs is not None:
- attrs.update(extra_attrs)
- return attrs
+ return {**base_attrs, **(extra_attrs or {})}
def value_from_datadict(self, data, files, name):
"""