@@ -102,8 +102,8 @@ 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 node .name_property in deprecated_mapbox_traces or node . name_property == "template" :
106+ buffer .write (f"import warnings \n " )
107107
108108 # Write class definition
109109 # ----------------------
@@ -375,9 +375,24 @@ def __init__(self"""
375375 f"""
376376 _v = arg.pop('{ name_prop } ', None)
377377 _v = { name_prop } if { name_prop } is not None else _v
378- if _v is not None:
379- self['{ name_prop } '] = _v"""
378+ if _v is not None:"""
380379 )
380+ if datatype_class == "Template" and name_prop == "data" :
381+ buffer .write (
382+ """
383+ # Template.data contains a 'scattermapbox' key, which causes a
384+ # go.Scattermapbox trace object to be created during validation.
385+ # In order to prevent false deprecation warnings from surfacing,
386+ # we suppress deprecation warnings for this line only.
387+ with warnings.catch_warnings():
388+ warnings.filterwarnings("ignore", category=DeprecationWarning)
389+ self["data"] = _v"""
390+ )
391+ else :
392+ buffer .write (
393+ f"""
394+ self['{ name_prop } '] = _v"""
395+ )
381396
382397 # ### Literals ###
383398 if literal_nodes :
@@ -413,7 +428,7 @@ def __init__(self"""
413428 if node .name_property in deprecated_mapbox_traces :
414429 buffer .write (
415430 f"""
416- warn(
431+ warnings. warn(
417432 "*{ node .name_property } * is deprecated!"
418433 + " Use *{ node .name_property .replace ("mapbox" , "map" )} * instead."
419434 + " Learn more at: https://plotly.com/python/mapbox-to-maplibre/",
0 commit comments