Don't create objects for None params
[osm/N2VC.git] / juju / client / facade.py
index 9fc3160..5b7ac35 100644 (file)
@@ -232,8 +232,8 @@ class {}(Type):
                     else:
                         source.append("{}self.{} = {}".format(INDENT * 2, arg_name, arg_name))
                 elif type(arg_type) is typing.TypeVar:
-                    source.append("{}self.{} = {}.from_json({})".format(
-                        INDENT * 2, arg_name, arg_type_name, arg_name))
+                    source.append("{}self.{} = {}.from_json({}) if {} else None".format(
+                        INDENT * 2, arg_name, arg_type_name, arg_name, arg_name))
                 else:
                     source.append("{}self.{} = {}".format(INDENT * 2, arg_name, arg_name))