Skip to content

Commit c86976b

Browse files
committed
Avoid using mutable default arguments where possible.
1 parent 43c471e commit c86976b

File tree

4 files changed

+7
-7
lines changed

4 files changed

+7
-7
lines changed

django/contrib/gis/maps/google/gmap.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,10 @@ class GoogleMap(object):
2929

3030
def __init__(self, key=None, api_url=None, version=None,
3131
center=None, zoom=None, dom_id='map',
32-
kml_urls=[], polylines=None, polygons=None, markers=None,
32+
kml_urls=(), polylines=None, polygons=None, markers=None,
3333
template='gis/google/google-map.js',
3434
js_module='geodjango',
35-
extra_context={}):
35+
extra_context=None):
3636

3737
# The Google Maps API Key defined in the settings will be used
3838
# if not passed in as a parameter. The use of an API key is
@@ -64,7 +64,7 @@ def __init__(self, key=None, api_url=None, version=None,
6464
# Setting the DOM id of the map, the load function, the JavaScript
6565
# template, and the KML URLs array.
6666
self.dom_id = dom_id
67-
self.extra_context = extra_context
67+
self.extra_context = extra_context or {}
6868
self.js_module = js_module
6969
self.template = template
7070
self.kml_urls = kml_urls

django/db/backends/base/schema.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ def __exit__(self, exc_type, exc_value, traceback):
9494

9595
# Core utility functions
9696

97-
def execute(self, sql, params=[]):
97+
def execute(self, sql, params=()):
9898
"""
9999
Executes the given SQL statement, with optional parameters.
100100
"""

django/db/models/fields/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ def __init__(self, verbose_name=None, name=None, primary_key=False,
142142
db_index=False, rel=None, default=NOT_PROVIDED, editable=True,
143143
serialize=True, unique_for_date=None, unique_for_month=None,
144144
unique_for_year=None, choices=None, help_text='', db_column=None,
145-
db_tablespace=None, auto_created=False, validators=[],
145+
db_tablespace=None, auto_created=False, validators=(),
146146
error_messages=None):
147147
self.name = name
148148
self.verbose_name = verbose_name # May be set by set_attributes_from_name
@@ -175,7 +175,7 @@ def __init__(self, verbose_name=None, name=None, primary_key=False,
175175
self.creation_counter = Field.creation_counter
176176
Field.creation_counter += 1
177177

178-
self._validators = validators # Store for deconstruction later
178+
self._validators = list(validators) # Store for deconstruction later
179179

180180
messages = {}
181181
for c in reversed(self.__class__.__mro__):

django/forms/fields.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ class Field(object):
6262

6363
def __init__(self, required=True, widget=None, label=None, initial=None,
6464
help_text='', error_messages=None, show_hidden_initial=False,
65-
validators=[], localize=False, disabled=False, label_suffix=None):
65+
validators=(), localize=False, disabled=False, label_suffix=None):
6666
# required -- Boolean that specifies whether the field is required.
6767
# True by default.
6868
# widget -- A Widget class, or instance of a Widget class, that should

0 commit comments

Comments
 (0)