From 97b493ade6bf4b97e586a6b8cbf8677963cdfbb0 Mon Sep 17 00:00:00 2001 From: Eyal Date: Mon, 15 Apr 2019 09:56:34 +0300 Subject: [PATCH] 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 --- mistral/actions/openstack/action_generator/base.py | 2 +- mistral/api/hooks/content_type.py | 2 +- mistral/lang/base.py | 2 +- mistral/lang/v2/on_clause.py | 2 +- mistral/lang/v2/policies.py | 2 +- mistral/lang/v2/publish.py | 2 +- mistral/lang/v2/retry_policy.py | 2 +- mistral/lang/v2/task_defaults.py | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) diff --git a/mistral/actions/openstack/action_generator/base.py b/mistral/actions/openstack/action_generator/base.py index 75e049b28..876c5f465 100644 --- a/mistral/actions/openstack/action_generator/base.py +++ b/mistral/actions/openstack/action_generator/base.py @@ -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 diff --git a/mistral/api/hooks/content_type.py b/mistral/api/hooks/content_type.py index cb4eda535..dd92a561d 100644 --- a/mistral/api/hooks/content_type.py +++ b/mistral/api/hooks/content_type.py @@ -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 diff --git a/mistral/lang/base.py b/mistral/lang/base.py index 57fed494a..abfec75f3 100644 --- a/mistral/lang/base.py +++ b/mistral/lang/base.py @@ -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( diff --git a/mistral/lang/v2/on_clause.py b/mistral/lang/v2/on_clause.py index 56498d96f..abd952b98 100644 --- a/mistral/lang/v2/on_clause.py +++ b/mistral/lang/v2/on_clause.py @@ -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): diff --git a/mistral/lang/v2/policies.py b/mistral/lang/v2/policies.py index b18e0d195..a9a4c9c9a 100644 --- a/mistral/lang/v2/policies.py +++ b/mistral/lang/v2/policies.py @@ -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): diff --git a/mistral/lang/v2/publish.py b/mistral/lang/v2/publish.py index 9515aa338..0c477b28d 100644 --- a/mistral/lang/v2/publish.py +++ b/mistral/lang/v2/publish.py @@ -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): diff --git a/mistral/lang/v2/retry_policy.py b/mistral/lang/v2/retry_policy.py index cc69149f3..c2e47e04b 100644 --- a/mistral/lang/v2/retry_policy.py +++ b/mistral/lang/v2/retry_policy.py @@ -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): diff --git a/mistral/lang/v2/task_defaults.py b/mistral/lang/v2/task_defaults.py index 08f8bee72..7c4cc3b19 100644 --- a/mistral/lang/v2/task_defaults.py +++ b/mistral/lang/v2/task_defaults.py @@ -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):