@@ -102,8 +102,11 @@ def build_datatype_py(node):
102102 )
103103 buffer .write (f"import copy as _copy\n " )
104104
105- if node .name_property in deprecated_mapbox_traces :
106- buffer .write (f"from warnings import warn\n " )
105+ if (
106+ node .name_property in deprecated_mapbox_traces
107+ or node .name_property == "template"
108+ ):
109+ buffer .write (f"import warnings\n " )
107110
108111 # Write class definition
109112 # ----------------------
@@ -375,9 +378,24 @@ def __init__(self"""
375378 f"""
376379 _v = arg.pop('{ name_prop } ', None)
377380 _v = { name_prop } if { name_prop } is not None else _v
378- if _v is not None:
379- self['{ name_prop } '] = _v"""
381+ if _v is not None:"""
380382 )
383+ if datatype_class == "Template" and name_prop == "data" :
384+ buffer .write (
385+ """
386+ # Template.data contains a 'scattermapbox' key, which causes a
387+ # go.Scattermapbox trace object to be created during validation.
388+ # In order to prevent false deprecation warnings from surfacing,
389+ # we suppress deprecation warnings for this line only.
390+ with warnings.catch_warnings():
391+ warnings.filterwarnings("ignore", category=DeprecationWarning)
392+ self["data"] = _v"""
393+ )
394+ else :
395+ buffer .write (
396+ f"""
397+ self['{ name_prop } '] = _v"""
398+ )
381399
382400 # ### Literals ###
383401 if literal_nodes :
@@ -413,7 +431,7 @@ def __init__(self"""
413431 if node .name_property in deprecated_mapbox_traces :
414432 buffer .write (
415433 f"""
416- warn(
434+ warnings. warn(
417435 "*{ node .name_property } * is deprecated!"
418436 + " Use *{ node .name_property .replace ("mapbox" , "map" )} * instead."
419437 + " Learn more at: https://plotly.com/python/mapbox-to-maplibre/",
0 commit comments