From 502bb4a37f21045b97dccd8b5c6945c0b6927b40 Mon Sep 17 00:00:00 2001 From: Przemyslaw Kaminski Date: Wed, 16 Sep 2015 11:20:33 +0200 Subject: [PATCH] Don't use dicts as default values for args --- solar/solar/core/resource/resource.py | 6 ++++-- solar/solar/core/resource/virtual_resource.py | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/solar/solar/core/resource/resource.py b/solar/solar/core/resource/resource.py index 35f9acac..65dfa2e4 100644 --- a/solar/solar/core/resource/resource.py +++ b/solar/solar/core/resource/resource.py @@ -39,7 +39,8 @@ class Resource(object): # Create @dispatch(str, str) - def __init__(self, name, base_path, args={}, tags=None, virtual_resource=None): + def __init__(self, name, base_path, args=None, tags=None, virtual_resource=None): + args = args or {} self.name = name if base_path: metadata = read_meta(base_path) @@ -86,7 +87,8 @@ class Resource(object): k: v for k, v in ret.items() if os.path.isfile(v) } - def create_inputs(self, args={}): + def create_inputs(self, args=None): + args = args or {} for name, v in self.db_obj.meta_inputs.items(): value = args.get(name, v.get('value')) diff --git a/solar/solar/core/resource/virtual_resource.py b/solar/solar/core/resource/virtual_resource.py index e2522d9f..d9e32bc3 100644 --- a/solar/solar/core/resource/virtual_resource.py +++ b/solar/solar/core/resource/virtual_resource.py @@ -24,7 +24,8 @@ from solar.core import resource from solar.core import signals -def create(name, base_path, args={}, virtual_resource=None): +def create(name, base_path, args=None, virtual_resource=None): + args = args or {} if isinstance(base_path, provider.BaseProvider): base_path = base_path.directory @@ -47,7 +48,8 @@ def create(name, base_path, args={}, virtual_resource=None): return rs -def create_resource(name, base_path, args={}, virtual_resource=None): +def create_resource(name, base_path, args=None, virtual_resource=None): + args = args or {} if isinstance(base_path, provider.BaseProvider): base_path = base_path.directory