File tree 1 file changed +8
-3
lines changed
1 file changed +8
-3
lines changed Original file line number Diff line number Diff line change @@ -81,6 +81,9 @@ def build_datatype_py(node):
81
81
# -------
82
82
buffer .write (
83
83
f'from plotly.basedatatypes import { node .name_base_datatype } \n ' )
84
+ buffer .write (
85
+ f'import copy\n ' )
86
+
84
87
85
88
# Write class definition
86
89
# ----------------------
@@ -210,12 +213,14 @@ def __init__(self""")
210
213
arg = {{}}
211
214
elif isinstance(arg, self.__class__):
212
215
arg = arg.to_plotly_json()
213
- elif not isinstance(arg, dict):
216
+ elif isinstance(arg, dict):
217
+ arg = copy.copy(arg)
218
+ else:
214
219
raise ValueError(\" \" \" \\
215
220
The first argument to the { class_name }
216
221
constructor must be a dict or
217
222
an instance of { class_name } \" \" \" )
218
-
223
+
219
224
# Import validators
220
225
# -----------------
221
226
from plotly.validators{ node .parent_dotpath_str } import (
@@ -237,7 +242,7 @@ def __init__(self""")
237
242
name_prop = subtype_node .name_property
238
243
buffer .write (f"""
239
244
v = arg.pop('{ name_prop } ', None)
240
- self.{ name_prop } = { name_prop } or v""" )
245
+ self.{ name_prop } = { name_prop } if { name_prop } is not None else v""" )
241
246
242
247
# ### Literals ###
243
248
if literal_nodes :
You can’t perform that action at this time.
0 commit comments