File tree Expand file tree Collapse file tree 1 file changed +8
-3
lines changed Expand file tree Collapse file tree 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):
8181 # -------
8282 buffer .write (
8383 f'from plotly.basedatatypes import { node .name_base_datatype } \n ' )
84+ buffer .write (
85+ f'import copy\n ' )
86+
8487
8588 # Write class definition
8689 # ----------------------
@@ -210,12 +213,14 @@ def __init__(self""")
210213 arg = {{}}
211214 elif isinstance(arg, self.__class__):
212215 arg = arg.to_plotly_json()
213- elif not isinstance(arg, dict):
216+ elif isinstance(arg, dict):
217+ arg = copy.copy(arg)
218+ else:
214219 raise ValueError(\" \" \" \\
215220The first argument to the { class_name }
216221constructor must be a dict or
217222an instance of { class_name } \" \" \" )
218-
223+
219224 # Import validators
220225 # -----------------
221226 from plotly.validators{ node .parent_dotpath_str } import (
@@ -237,7 +242,7 @@ def __init__(self""")
237242 name_prop = subtype_node .name_property
238243 buffer .write (f"""
239244 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""" )
241246
242247 # ### Literals ###
243248 if literal_nodes :
You can’t perform that action at this time.
0 commit comments