Don't use default mutable parameter

Using default mutable parameter is bad.
Default parameters are evaluated only once
if you mutate it you will get unexpected results.
Since we don't mutate here the default paramter, make
sure it is unmutable.

Change-Id: Ib5c451a8c8cad7b6c9a009369c1c039563023368
This commit is contained in:
Eyal 2019-04-15 09:56:34 +03:00
parent 401eeddb2d
commit 97b493ade6
8 changed files with 8 additions and 8 deletions

View File

@ -70,7 +70,7 @@ class OpenStackActionGenerator(action_generator.ActionGenerator):
base_action_class = None
@classmethod
def prepare_action_inputs(cls, origin_inputs, added=[]):
def prepare_action_inputs(cls, origin_inputs, added=()):
"""Modify action input string.
Sometimes we need to change the default action input definition for

View File

@ -16,7 +16,7 @@ from pecan import hooks
class ContentTypeHook(hooks.PecanHook):
def __init__(self, content_type, methods=['GET']):
def __init__(self, content_type, methods=('GET',)):
"""Content type hook.
This hook is needed for changing content type of

View File

@ -158,7 +158,7 @@ class BaseSpec(object):
_version = '2.0'
@classmethod
def get_schema(cls, includes=['meta', 'definitions']):
def get_schema(cls, includes=('meta', 'definitions')):
schema = copy.deepcopy(cls._schema)
schema['properties'] = utils.merge_dicts(

View File

@ -107,7 +107,7 @@ class OnClauseSpec(base.BaseSpec):
self._next = prepare_next_clause(data.get('next'))
@classmethod
def get_schema(cls, includes=['definitions']):
def get_schema(cls, includes=('definitions',)):
return super(OnClauseSpec, cls).get_schema(includes)
def get_publish(self):

View File

@ -34,7 +34,7 @@ class PoliciesSpec(base.BaseSpec):
}
@classmethod
def get_schema(cls, includes=['definitions']):
def get_schema(cls, includes=('definitions',)):
return super(PoliciesSpec, cls).get_schema(includes)
def __init__(self, data, validate):

View File

@ -37,7 +37,7 @@ class PublishSpec(base.BaseSpec):
self._atomic = self._data.get('atomic')
@classmethod
def get_schema(cls, includes=['definitions']):
def get_schema(cls, includes=('definitions',)):
return super(PublishSpec, cls).get_schema(includes)
def validate_semantics(self):

View File

@ -51,7 +51,7 @@ class RetrySpec(base.BaseSpec):
}
@classmethod
def get_schema(cls, includes=['definitions']):
def get_schema(cls, includes=('definitions',)):
return super(RetrySpec, cls).get_schema(includes)
def __init__(self, data, validate):

View File

@ -50,7 +50,7 @@ class TaskDefaultsSpec(base.BaseSpec):
}
@classmethod
def get_schema(cls, includes=['definitions']):
def get_schema(cls, includes=('definitions',)):
return super(TaskDefaultsSpec, cls).get_schema(includes)
def __init__(self, data, validate):