-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix: Display deprecated warnings for mapbox traces #4900
Conversation
@LiamConnors When you have a chance, could you sanity check whether the warnings are working as expected for you on this branch? I.e. that we see a warning when using the deprecated traces, but no warnings otherwise. |
It's working as expected. Looks good to me. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thank you
+ " Use *{node.name_property.replace("mapbox", "map")}* instead." | ||
+ " Learn more at: https://plotly.com/python/mapbox-to-maplibre/", | ||
stacklevel=2, | ||
category=DeprecationWarning, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@emilykl Good improvement. And I can approve this PR.
As follow ups to this PR:
Could you possibly
- double check that
stacklevel=2
is the best option we could use? - should we use similar
stacklevel
andcategory
options for other warnings in plotly.py?
Thank you!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe stacklevel=2
is the correct option in this case -- it causes the warning to appear to be emitted at the place in the user's code where they have called the deprecated function, for example:
Making a go.Choroplethmapbox figure...
/Users/ekl/code/plotly.py/my_script.py:32: DeprecationWarning:
*choroplethmapbox* is deprecated! Use *choroplethmap* instead. Learn more at: https://plotly.com/python/mapbox-to-maplibre/
(Also, for DeprecationWarning
specifically, using any other stacklevel
for these deprecations causes the warning to not appear at all.)
It's just coincidence that stacklevel=2
is the correct option in this case for both the go
and px
deprecations... the correct stacklevel will differ in every case depending on exactly where the warning is being emitted.
I don't think it's worth the effort to go through the codebase and clean up existing warnings, but I do think it makes sense to use stacklevel
and category
consistently going forward. It seems at least some of the warnings already in place in Plotly.py are using them correctly.
Closes #4730.
Adds deprecation warnings which are printed to the console when using one of the following objects / functions:
graph objects:
go.Choroplethmapbox
go.Densitymapbox
go.Scattermapbox
express:
px.choropleth_mapbox
px.density_mapbox
px.scatter_mapbox
px.line_mapbox
Since the graph objects files are generated by codegen, this PR also modifies the codegen process to automatically add the deprecation warnings to the generated files.