Code cleanup for passing mutable object as default argument
Code cleanup for passing mutable object as default argument. Change-Id: Id1f557a3812da4fd831861a87de2cab1b8645c97
This commit is contained in:
parent
7ac2ac1ea2
commit
41eca8d586
|
@ -26,7 +26,7 @@ from tacker.openstack.common import log as logging
|
|||
LOG = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def get_filters(request, attr_info, skips=[]):
|
||||
def get_filters(request, attr_info, skips=None):
|
||||
"""Extracts the filters from the request string.
|
||||
|
||||
Returns a dict of lists for the filters:
|
||||
|
@ -35,6 +35,8 @@ def get_filters(request, attr_info, skips=[]):
|
|||
{'check': [u'a', u'b'], 'name': [u'Bob']}
|
||||
"""
|
||||
res = {}
|
||||
if skips is None:
|
||||
skips = []
|
||||
for key, values in request.GET.dict_of_lists().iteritems():
|
||||
if key in skips:
|
||||
continue
|
||||
|
|
|
@ -30,8 +30,8 @@ class DBError(Exception):
|
|||
|
||||
class DBDuplicateEntry(DBError):
|
||||
"""Wraps an implementation specific exception."""
|
||||
def __init__(self, columns=[], inner_exception=None):
|
||||
self.columns = columns
|
||||
def __init__(self, columns=None, inner_exception=None):
|
||||
self.columns = columns if columns else []
|
||||
super(DBDuplicateEntry, self).__init__(inner_exception)
|
||||
|
||||
|
||||
|
|
|
@ -43,8 +43,9 @@ class StubExtension(object):
|
|||
|
||||
class StubPlugin(object):
|
||||
|
||||
def __init__(self, supported_extensions=[]):
|
||||
self.supported_extension_aliases = supported_extensions
|
||||
def __init__(self, supported_extensions=None):
|
||||
self.supported_extension_aliases = supported_extensions \
|
||||
if supported_extensions else []
|
||||
|
||||
|
||||
class ExtensionExpectingPluginInterface(StubExtension):
|
||||
|
|
|
@ -134,9 +134,11 @@ class APIv2TestCase(APIv2TestBase):
|
|||
fields.extend(policy_attrs)
|
||||
return fields
|
||||
|
||||
def _get_collection_kwargs(self, skipargs=[], **kwargs):
|
||||
def _get_collection_kwargs(self, skipargs=None, **kwargs):
|
||||
args_list = ['filters', 'fields', 'sorts', 'limit', 'marker',
|
||||
'page_reverse']
|
||||
if skipargs is None:
|
||||
skipargs = []
|
||||
args_dict = dict((arg, mock.ANY)
|
||||
for arg in set(args_list) - set(skipargs))
|
||||
args_dict.update(kwargs)
|
||||
|
|
|
@ -160,8 +160,10 @@ class DeviceHeat(abstract_driver.DeviceAbstractDriver):
|
|||
}
|
||||
}
|
||||
|
||||
def handle_port_creation(network_param, ip_list=[],
|
||||
def handle_port_creation(network_param, ip_list=None,
|
||||
mgmt_port=False):
|
||||
if ip_list is None:
|
||||
ip_list = []
|
||||
port = '%s-%s-port' % (vdu_id, network_param['network'])
|
||||
port_dict = make_port_dict()
|
||||
if mgmt_port:
|
||||
|
|
Loading…
Reference in New Issue