Fix mutable default arguments

make the default arguments assignment looks good.

Change-Id: I5c4a76d85d3acd5b4348ef70e593e195af4b79e1
This commit is contained in:
caoyue 2016-04-26 19:26:57 +08:00
parent 4de857f0fb
commit 0b4b9d8327
5 changed files with 6 additions and 12 deletions

View File

@ -35,8 +35,7 @@ def get_filters(request, attr_info, skips=None):
{'check': [u'a', u'b'], 'name': [u'Bob']}
"""
res = {}
if skips is None:
skips = []
skips = skips or []
for key, values in iteritems(request.GET.dict_of_lists()):
if key in skips:
continue

View File

@ -48,8 +48,7 @@ class Controller(object):
def __init__(self, plugin, collection, resource, attr_info,
allow_bulk=False, member_actions=None, parent=None,
allow_pagination=False, allow_sorting=False):
if member_actions is None:
member_actions = []
member_actions = member_actions or []
self._plugin = plugin
self._collection = collection.replace('-', '_')
self._resource = resource.replace('-', '_')

View File

@ -59,8 +59,7 @@ def build_resource_info(plural_mappings, resource_map, which_service,
resources = []
if not which_service:
which_service = constants.CORE
if action_map is None:
action_map = {}
action_map = action_map or {}
plugin = manager.TackerManager.get_service_plugins()[which_service]
for collection_name in resource_map:
resource_name = plural_mappings[collection_name]

View File

@ -252,10 +252,8 @@ def compare_elements(a, b):
This method doesn't consider ordering
"""
if a is None:
a = []
if b is None:
b = []
a = a or []
b = b or []
return set(a) == set(b)

View File

@ -207,8 +207,7 @@ class DeviceHeat(abstract_driver.DeviceAbstractDriver):
def handle_port_creation(network_param, ip_list=None,
mgmt_port=False):
if ip_list is None:
ip_list = []
ip_list = ip_list or []
port = '%s-%s-port' % (vdu_id, network_param['network'])
port_dict = make_port_dict()
if mgmt_port: